geomean2: Geometric mean: product form

View source: R/geomean2.r

geomean2R Documentation

Geometric mean: product form

Description

Simple geometric mean function. The logarithm form (geomean) works somewhat better but can only handle non-zero positive values.

Usage

geomean2(x, na.rm = TRUE, all.na.result = NA)

Arguments

x

numeric vector

na.rm

as in base R functions "a logical value indicating whether NA values should be stripped before the computation proceeds."

all.na.result

Result to return if all values are NA. For some reason prod(numeric(0)) = 1, so the function will return 1 even if all x are NA.

Author(s)

Nikolai Klibansky

Examples

x <- c(1,2,10)
geomean(x)
geomean2(x)
mean(x)

nikolaifish/bamExtras documentation built on July 21, 2023, 8:26 a.m.