compute_weighted_mean: Compute (Weighted) Means for a Variable

View source: R/weighted_mean.R

compute_weighted_meanR Documentation

Compute (Weighted) Means for a Variable

Description

Compute (Weighted) Means for a Variable

Usage

compute_weighted_mean(var, wgt = NULL, na.rm = TRUE)

Arguments

var

A column refering to one of the variables in a LIS or LWS data frame.

wgt

A numeric vector of weights (e.g., .x$hpopwgt, .x$pwgt). Must be the same length as x.

na.rm

Logical; if TRUE, missing values in x and w are removed before computation. Default is TRUE.

Value

A numeric vector.

Examples

## Not run: 
data <- lissyrtools::lissyuse(data = "de20", vars = c("dhi", "age", "educ"))
compute_weighted_mean(data$de20$age, na.rm = TRUE)
compute_weighted_mean(data$de20$dhi, data$de20$hwgt)

## End(Not run)

JosepER/lissyrtools documentation built on June 12, 2025, 12:11 p.m.