View source: R/specific_calculations.R
geomean | R Documentation |
The geometric mean is useful when your values are imbalanced by outliers. Daniel McNichol wrote a very approachable article about this topic.
geomean(x, na.rm = TRUE)
x |
(Numeric) A vector. |
na.rm |
(Logical) If TRUE, NAs will be silently removed. |
This function is by Paul McMurdie and is "vectorized, zero- and NA-tolerant ... checks for any negative values, and returns a more informative and appropriate NaN respecting that geometric mean is not defined for negative values (but is for zeros)."
A numeric vector of length 1.
Paul McMurdie (https://stackoverflow.com/users/935950/paul-mcmurdie)
https://stackoverflow.com/a/25555105/5578429
vec <- c(1, 3, 9, 27, 81, 243, 729)
mean(vec)
#> [1] 156.1429
geomean(vec)
#> [1] 27
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.