Based on some posts in a thread on Stackoverflow http://stackoverflow.com/questions/2602583/geometric-mean-is-there-a-built-in This function checks for negative values, removes NA values per default and returns 0 if at least one element of the vector is 0.
geomean(x, na.rm = TRUE)
x | Vector of numbers |
---|---|
na.rm | Should NA values be omitted? |
The geometric mean
#> [1] 3#> [1] 3# NOT RUN { geomean(c(1, -3, 9)) # returns an error # }