You can use the harmonic.mean() function of the psych library to calculate the harmonic mean. If the package psych is not installed, you can install it by running command install.packages("psych").
> library(psych)> x <- seq(1,5)> x[1] 1 2 3 4 5> harmonic.mean(x)[1] 2.189781