wtd_mean | R Documentation |
Compute weighted mean.
wtd_mean(x, weights = NULL, na.rm = TRUE)
x |
A numeric vector. |
weights |
A numeric vector of weights. |
na.rm |
Set to FALSE to suppress checking for NAs |
Returns scalar vector of length one.
## Not run: set.seed(1)
x <- runif(500)
wts <- sample(1:6, 500, TRUE)
mn <- wtd_mean(x = x, weights = wts)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.