Learn R Programming

DescTools (version 0.99.7)

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 sd are restricted to positive inputs (because otherwise the answer can have an imaginary component). 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 DataLab