geometricMean | R Documentation |
The geometric mean is the nth root of n products or e to the mean log of x
.
geometricMean(x, ...)
## S4 method for signature 'AsIs'
geometricMean(x)
## S4 method for signature 'matrix'
geometricMean(x, MARGIN = 2L)
## S4 method for signature 'numeric'
geometricMean(x, removeNa = TRUE, zeroPropagate = FALSE)
x |
Object. |
MARGIN |
|
removeNa |
|
zeroPropagate |
|
... |
Additional arguments. |
This function should be fully zero- and NA
-tolerant. This calculation is
not particularly useful if there are elements that are <= 0 and will return
NaN
.
numeric
.
Updated 2021-10-14.
psych::geometric.mean()
.
## numeric ====
vec1 <- seq(from = 1L, to = 5L, by = 1L)
print(vec1)
geometricMean(vec1)
vec2 <- vec1^2L
print(vec2)
geometricMean(vec2)
## matrix ====
matrix <- matrix(
data = c(vec1, vec2),
ncol = 2L,
byrow = FALSE
)
print(matrix)
geometricMean(matrix)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.