psych (version 2.4.3)

geometric.mean: Find the geometric mean of a vector or columns of a data.frame.

Description

The geometric mean is the nth root of n products or e to the mean log of x. Useful for describing non-normal, i.e., geometric distributions.

Usage

geometric.mean(x,na.rm=TRUE)

Value

geometric mean(s) of x or x.df.

Arguments

x

a vector or data.frame

na.rm

remove NA values before processing

Author

William Revelle

Details

Useful for teaching how to write functions, also useful for showing the different ways of estimating central tendency.

See Also

harmonic.mean, mean

Examples

Run this code

x <- seq(1,5)
x2 <- x^2
x2[2] <- NA
X <- data.frame(x,x2)
geometric.mean(x)
geometric.mean(x2)
geometric.mean(X)
geometric.mean(X,na.rm=FALSE)

Run the code above in your browser using DataLab