View source: R/weighted_mean.R
compute_weighted_mean | R Documentation |
Compute (Weighted) Means for a Variable
compute_weighted_mean(var, wgt = NULL, na.rm = TRUE)
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 |
na.rm |
Logical; if |
A numeric vector.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.