## generate random lognormal data
d <- rlnorm(500,meanlog=0,sdlog=1)
# d has a mean on log scale of 0; thus, gm should be exp(0)~=1
# d has a sd on log scale of 1; thus, gsd should be exp(1)~=2.7
geomean(d)
geosd(d)
## Demonstrate handling of zeroes and negative values
x <- seq(0,5)
# this will given an error
try(geomean(x))
# this will only give a warning, but might not be what you want
geomean(x,zneg.rm=TRUE)
Run the code above in your browser using DataLab