Learn R Programming

beadplexr (version 0.5.0)

geometric_mean: Calculate geometric mean

Description

Calculate geometric mean

Usage

geometric_mean(.x)

Value

A single numeric value

Arguments

.x

A numeric to take the geometric mean of

Mean calculation

The geometric mean is given by:

$$ \left(\prod_{i=1}^n x_i \right)^\frac{1}{n} $$

but implemented as:

$$ \frac{1}{n}\exp{\sum_{i=1}^n\log(x_i)} $$

NAs are removed before calculation

Examples

Run this code
beadplexr:::geometric_mean(runif(10))

Run the code above in your browser using DataLab