Skip to contents

The harmonic mean is the reciprocal of the arithmetic mean of the reciprocals of a set of observations. It is a more robust measure of central tendency than the arithmetic mean in the presence of outliers since it tends to the smallest elements of a set of observations.

Usage

harm.mean(x, na.rm = FALSE, ...)

Arguments

x

an object containing a set of observations in a matrix, data frame or vector.

na.rm

logical by default set to FALSE. To remove NAs set argument to TRUE

...

additional arguments passed to or from other methods

Value

a numeric vector of length equal or greater than 1L

Examples

d <- rlnorm(60,1,1.4)
harm.mean(d)
#> [1] 1.173035

x <- matrix(rlnorm(60,1,1.4),ncol = 4)
mapply(harm.mean, as.data.frame(x))
#>        V1        V2        V3        V4 
#> 0.3281170 3.2186557 1.2562412 0.9474592