View source: R/tabul_group_fun.R
tabulate_micro_data | R Documentation |
tabulate grouped data with all margins, handling hierarchical variables
tabulate_micro_data(
df,
cat_vars = NULL,
hrc_vars = NULL,
pond_var = NULL,
resp_var = NULL,
marge_label = "Total"
)
df |
data.frame or data.table |
cat_vars |
vector of categorical variables but not hierarchical |
hrc_vars |
named list (name = VAR final name, value = VAR current names) |
pond_var |
weight (NULL if no weight is used) |
resp_var |
vector of response variables (NULL to only compute frequency table) |
marge_label |
label of margins (applied to all cat and hrc variables) |
a tibble
library(data.table)
data("indiv_dt")
#Non hierarchical variables
res_all_dtp <- tabulate_micro_data(
df = indiv_dt,
#categorical but not hierarchical variables
cat_vars = c("A10", "SIZE","CJ"),
#weight var
pond_var = "WEIGHT",
#response variable
resp_var = "TURNOVER",
# Labels of the margins
marge_label = "Total"
)
str(res_all_dtp)
#With one hierarchical variable
res_all_dtph <- tabulate_micro_data(
df = indiv_dt,
#categorical but not hierarchical variables
cat_vars = c("SIZE","CJ"),
#categorical nested variables
hrc_vars = list(ACTIVITY = c("A10","A21")),
pond_var = "WEIGHT",
resp_var = c("TURNOVER","PRODUCTION"),
marge_label = "Total"
)
str(res_all_dtph)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.