gmean: Geometric mean

Description Usage Arguments Details Value Author(s) Examples

Description

Computes the geometric mean(s) of a numeric vector, matrix or data.frame

Usage

1
2
3
gmean_sum(x, margin = NULL)

gmean(x, margin = NULL)

Arguments

x

matrix or data.frame with numeric entries

margin

a vector giving the subscripts which the function will be applied over, 1 indicates rows, 2 indicates columns, 3 indicates all values.

Details

gmean_sum calculates the totals based on geometric means while gmean calculates geometric means on rows (margin = 1), on columns (margin = 2), or on all values (margin = 3)

Value

geometric means (if gmean is used) or totals (if gmean_sum is used)

Author(s)

Matthias Templ

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data("precipitation")
gmean_sum(precipitation)
gmean_sum(precipitation, margin = 2)
gmean_sum(precipitation, margin = 1)
gmean_sum(precipitation, margin = 3)
addmargins(precipitation)
addmargins(precipitation, FUN = gmean_sum)
addmargins(precipitation, FUN = mean)
addmargins(precipitation, FUN = gmean)

data("arcticLake", package = "robCompositions")
gmean(arcticLake$sand)
gmean(as.numeric(arcticLake[1, ]))
gmean(arcticLake)
gmean(arcticLake, margin = 1)
gmean(arcticLake, margin = 2)
gmean(arcticLake, margin = 3)

robCompositions documentation built on Jan. 13, 2021, 10:07 p.m.