calculate_mean {dynutils} | R Documentation |
Calculate a (weighted) mean between vectors or a list of vectors
Description
This function supports the arithmetic, geometric and harmonic mean.
Usage
calculate_mean(..., method, weights = NULL)
calculate_harmonic_mean(..., weights = NULL)
calculate_geometric_mean(..., weights = NULL)
calculate_arithmetic_mean(..., weights = NULL)
Arguments
... |
Can be:
|
method |
The aggregation function. Must be one of |
weights |
Weights with the same length as |
Examples
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))
[Package dynutils version 1.0.11 Index]