geometricmean: Calculating the Geometric Mean

Description Usage Arguments Value Examples

Description

Calculates the geometric mean of a set of positive numbers. The function calculates the product of every number in the vector and takes the nth root, where n is the number of elements in the vector.

Usage

1
geometricmean(input, na.rm = FALSE)

Arguments

input

a vector of numbers

na.rm

true or false for whether to remove NA's before performing the calculation

Value

A number

Examples

1
2
3
4
5
6
7
8
a <- c(3,9,5,8)
geometricmean(a)

b <- c(NA,3,NA,7,9,2)
geometricmean(b)

d <- c(NA,3,NA,7,9,2)
geometricmean(d,na.rm=T)

Andy-McCarthy/BasicMath documentation built on May 27, 2019, 7:24 a.m.