wtd_mean: weighted mean

Description Usage Arguments Value Examples

View source: R/SummaryStatistics.R

Description

wtd_mean returns the weighted mean of a variable. It's a tidy-compatible wrapper around stats::weighted.mean().

Usage

1
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

1
2
3
4
wtd_mean(illinois, age, weight)

library(dplyr)
illinois %>% wtd_mean(age, weight)

pollster documentation built on Aug. 25, 2020, 5:08 p.m.