Learn R Programming

DescTools (version 0.99.6)

Hmean: Harmonic mean

Description

Calculates the harmonic mean of a vector x.

Usage

Hmean(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

Use sapply to calculate the measures from data frame, resp. from a matrix.

See Also

Gmean

Examples

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

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

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

Run the code above in your browser using DataLab