geo_mean: Geometric mean

geo_meanR Documentation

Geometric mean

Description

Defined as: \loadmathjax \mjdeqn \left(\prod_i=1^n x_i\right)^\frac1n = \sqrt[n]x_1 x_2 \cdots x_n ASCII representation

Usage

geo_mean(x, na.rm = FALSE)

Arguments

x

Numeric

na.rm

Remove any NA values prior to calculation

Details

Based heavily on the geoMean() function in the EnvStats package by alexkowa, and various stackoverflow posts.

Examples

x <- rnorm(100, 1, 0.3)
geo_mean(x)

x <- c(x, NA)
geo_mean(x)
geo_mean(x, na.rm = TRUE)


Acanthiza/envTrend documentation built on Nov. 16, 2023, 4:24 p.m.