wtd_mean {pollster} | R Documentation |
weighted mean
Description
wtd_mean
returns the weighted mean of a variable. It's a tidy-compatible
wrapper around stats::weighted.mean().
Usage
wtd_mean(df, variable, weight)
Arguments
df |
The data source |
variable |
the variable, it should be numeric |
weight |
The weighting variable |
Value
a numeric value
Examples
wtd_mean(illinois, age, weight)
library(dplyr)
illinois %>% wtd_mean(age, weight)
[Package pollster version 0.1.6 Index]