Calculate the Geometric Mean, Allowing for Zeroes
Calculate the geometric mean of a numeric vector, possibly excluding zeroes and/or adding an offset to compensate for zero values.
calcGM(x, offset = 0, exzero = TRUE)
x
: vector of numbersoffset
: value to add to all components, including zeroesexzero
: if TRUE
, exclude zeroes (but still add the offset)Geometric mean of the modified vector x + offset
Rowan Haigh, Pacific Biological Station, Fisheries and Oceans Canada, Nanaimo BC
NA
values are automatically removed from x
local(envir=.PBSmodEnv,expr={ calcGM(c(0,1,100)) calcGM(c(0,1,100),offset=0.01,exzero=FALSE) })
Downloads (last 30 days):