Skip to contents

Compute the harmonic mean of a numeric vector, ignoring NA values.

Usage

har_mean(x, na.rm = T)

Arguments

x

A numeric vector.

na.rm

Logical (default TRUE). Whether to remove NA values.

Value

A numeric scalar representing the harmonic mean.

Details

Harmonic mean is useful when averaging rates or reciprocal quantities. It is defined as length(x) / sum(1/x).