wtd_mean: weighted mean

View source: R/SummaryStatistics.R

wtd_meanR 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)

jdjohn215/pollster documentation built on May 19, 2023, 4:34 p.m.