harmonic.mean {psych}R Documentation

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)

Arguments

x a vector, matrix, or data.frame

Details

Included as an example for teaching about functions. As well as for a discussion of how to estimate central tendencies.

Value

The harmonic mean(s)

Note

Included as a simple demonstration of how to write a function

Examples

##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--    or do  help(data=index)  for the standard data sets.
x <- seq(1,5)
x2 <- x^2
harmonic.mean(x)
harmonic.mean(x2)
## The function is currently defined as
function(x) { 1/(mean(1/x)) }

[Package psych version 1.0-18 Index]