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)

pollster documentation built on May 31, 2023, 7:39 p.m.