Skip to contents

Calculates the Geometric Mean from a vector

Usage

geometric.mean(x, logged = FALSE, na.rm = TRUE);

Arguments

x

A vector. Values need to be positive if on the log scale.

logged

Indicate whether data is log-transformed or not. Defaults to FALSE. If logged then the function is equivelant to the arithmetic mean.

na.rm

Should NAs be removed.

Value

A value corresponding to the geometric mean

Author

Daryl Waggott

Examples

x <- abs(rnorm(100));
mean1 <- geometric.mean(x);
mean2 <- mean(x, na.rm = TRUE);
median1 <- median(x, na.rm = TRUE);