View source: R/weighted_count.R
compute_weighted_count | R Documentation |
Compute (Weighted) Counts or Percentages for a Categorical Variable
compute_weighted_count(var, wgt = NULL, na.rm = FALSE, percent = FALSE)
var |
A column refering to one of the categorical 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 |
percent |
Logical; if |
A numeric vector, with category labels as names.
## Not run:
data <- lissyrtools::lissyuse(data = "de20", vars = c("dhi", "age", "educ"))
compute_weighted_count(data$de20$educ, na.rm = TRUE)
compute_weighted_count(data$de20$educ, percent = TRUE)
compute_weighted_count(data$de20$educ, na.rm = TRUE, percent = TRUE)
compute_weighted_count(data$de20$educ, data$de20$ppopwgt, na.rm = TRUE, percent = TRUE)
compute_weighted_count(data$de20$educ, data$de20$ppopwgt, percent = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.