harmonic_mean: Find the harmonic mean of a vector, matrix, or columns of a data.frame
Description
The harmonic mean is merely the reciprocal of the arithmetic mean of the reciprocals.
Usage
harmonic_mean(x, na.rm = TRUE, zero = TRUE)
Value
The harmonic mean of x
Arguments
- x
A vector, matrix, or data.frame
- na.rm
Logical. If TRUE
, remove NA
values before processing
- zero
Logical, If TRUE
, if there are any zeroes, return 0, else, return the harmonic mean of the non-zero elements
Author
Adapted from psych::harmonic.mean()
by William Revelle