powered by
Weighted Mean, Median, SD, and MAD
weighted_mean(x, weights = NULL, verbose = TRUE, ...)weighted_median(x, weights = NULL, verbose = TRUE, ...)weighted_sd(x, weights = NULL, verbose = TRUE, ...)weighted_mad(x, weights = NULL, constant = 1.4826, verbose = TRUE, ...)
weighted_median(x, weights = NULL, verbose = TRUE, ...)
weighted_sd(x, weights = NULL, verbose = TRUE, ...)
weighted_mad(x, weights = NULL, constant = 1.4826, verbose = TRUE, ...)
an object containing the values whose weighted mean is to be computed.
A numerical vector of weights the same length as x giving the weights to use for elements of x.
x
Show warning when weights are negative?
weights
If weights = NULL, x is passed to the non-weighted function.
weights = NULL
arguments to be passed to or from methods.
scale factor.
## GPA from Siegel 1994 x <- c(3.7, 3.3, 3.5, 2.8) wt <- c(5, 5, 4, 1) / 15 weighted_mean(x, wt) weighted_median(x, wt) weighted_sd(x, wt) weighted_mad(x, wt)
Run the code above in your browser using DataLab