| wtd_mean | R Documentation |
wtd_mean returns the weighted mean of a variable. It's a tidy-compatible
wrapper around stats::weighted.mean().
wtd_mean(df, variable, weight)
df |
The data source |
variable |
the variable, it should be numeric |
weight |
The weighting variable |
a numeric value
wtd_mean(illinois, age, weight) library(dplyr) illinois %>% wtd_mean(age, weight)