DescTools (version 0.99.11)

Gmean: Geometric Mean and Standard Deviation

Description

Calculates the geometric mean and the geometric standard deviation of a vector x.

Usage

Gmean(x, na.rm = FALSE)

Gsd(x, na.rm = FALSE)

Arguments

x
a positive numeric vector. An object which is not a vector is coerced (if possible) by as.vector.
na.rm
logical, indicating whether NA values should be stripped before the computation proceeds. Defaults to FALSE.

Value

  • a numeric value.

Details

The geometric mean and geometric sd are restricted to positive inputs (because otherwise the answer can have an imaginary component). Hence if any argument is negative, then the result is NA. If any argument is zero, then the geometric mean is zero. It is defined as $$\sqrt[n]{x_{1}\cdot x_{2}\cdot x_{3} \ldots \cdot x_{n}}$$ Use sapply to calculate the measures from data frame, resp. from a matrix.

See Also

mean, Hmean

Examples

Run this code
x <- runif(5)
Gmean(x)

m <- matrix(runif(50), nrow = 10)
apply(m, 2, Gmean)

sapply(as.data.frame(m), Gmean)

Run the code above in your browser using DataCamp Workspace