geomean2 | R Documentation |
Simple geometric mean function. The logarithm form (geomean) works somewhat better but can only handle non-zero positive values.
geomean2(x, na.rm = TRUE, all.na.result = NA)
x |
numeric vector |
na.rm |
as in base R functions "a logical value indicating whether NA values should be stripped before the computation proceeds." |
all.na.result |
Result to return if all values are NA. For some reason prod(numeric(0)) = 1, so the function will return 1 even if all x are NA. |
Nikolai Klibansky
x <- c(1,2,10)
geomean(x)
geomean2(x)
mean(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.