powered by
Get the mean applying some weights
weighted_mean(y, weights = NULL, norm = TRUE)
the weighted mean
a vector to compute the mean for
the vector of weights, can be NULL, then will just return mean
normalize the weights so that they have mean of 1, default is to normalize
y <- rnorm(100) w <- runif(100) weighted_mean(y, weights = w)
Run the code above in your browser using DataLab