mean2 {REAT} | R Documentation |
Calculation of mean (extended)
Description
Calculating the arithmetic mean, weighted or non-weighted, or the geometric mean
Usage
mean2(x, weighting = NULL, output = "mean", na.rm = TRUE)
Arguments
x |
a |
weighting |
a |
output |
argument to specify the output ( |
na.rm |
logical argument that whether NA values should be extracted or not |
Details
This function uses the formula for the weighted arithmetic mean from Sheret (1984).
Value
Single numeric value. If output = "mean"
and weighting
is specified, the function returns a weighted arithmetic mean. If output = "geom"
, the geometric mean is returned.
Author(s)
Thomas Wieland
References
Bahrenberg, G./Giese, E./Mevenkamp, N./Nipper, J. (2010): “Statistische Methoden in der Geographie. Band 1: Univariate und bivariate Statistik”. Stuttgart: Borntraeger.
Sheret, M. (1984): “The Coefficient of Variation: Weighting Considerations”. In: Social Indicators Research, 15, 3, p. 289-295.
See Also
Examples
avector <- c(5, 17, 84, 55, 39)
mean(avector)
mean2(avector)
wvector <- c(9, 757, 44, 18, 682)
mean2 (avector, weighting = wvector)
mean2 (avector, output = "geom")