calculate_mean: Calculate a (weighted) mean between vectors or a list of...

Description Usage Arguments Examples

View source: R/calculate_mean.R

Description

This function supports the arithmetic, geometric and harmonic mean.

Usage

1
2
3
4
5
6
7

Arguments

...

Can be:

  • One numeric vector

  • A list containg numeric vectors

  • Numeric vectors given as separate inputs

method

The aggregation function. Must be one of "arithmetic", "geometric", and "harmonic".

weights

Weights with the same length as ....

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
calculate_arithmetic_mean(0.1, 0.5, 0.9)
calculate_geometric_mean(0.1, 0.5, 0.9)
calculate_harmonic_mean(0.1, 0.5, 0.9)
calculate_mean(.1, .5, .9, method = "harmonic")

# example with multiple vectors
calculate_arithmetic_mean(c(0.1, 0.9), c(0.2, 1))

# example with a list of vectors
vectors <- list(c(0.1, 0.2), c(0.4, 0.5))
calculate_geometric_mean(vectors)

# example of weighted means
calculate_geometric_mean(c(0.1, 10), c(0.9, 20), c(0.5, 2), weights = c(1, 2, 5))

dynutils documentation built on May 6, 2019, 1:03 a.m.