
Geometric Mean
geomean.RdFunction for calculating the geometric mean of a set of positive numbers.
Value
If all values of x are positive, the geometric mean is returned as a numeric vector of length one. If any values are non-positive, NA is returned.
Examples
x <- c(1, 10, 100)
mean(x)
#> [1] 37
geomean(x)
#> [1] 10
geomean(c(-1,x))
#> Warning: All values must be positive to calculate the geometric mean.
#> [1] NA
geomean(c(0,x))
#> Warning: All values must be positive to calculate the geometric mean.
#> [1] NA
geomean(c(NA,x))
#> [1] NA
geomean(c(NA,x), na.rm=TRUE)
#> [1] 10