View source: R/table_basicstats.R
table_basicstats | R Documentation |
Compute basic statistics of the number of members per group per household
table_basicstats(df, hh_id, group_by_var)
df |
a data frame of household data where the rows represent members of the households in the sample |
hh_id |
string (length 1) indicating the name of the variable in |
group_by_var |
string (length 1) to pass to |
A tibble with rows for each level of group_by_var
and "Total" and columns for the Mean (SD), Median and Range of the number of people in each group per household.
Includes a call to tidyr::complete()
, which causes the function to be a bit slow.
Other table functions:
table_unweightedpctn()
,
table_weightedpct()
#create dummy table of household data, where each row represents one member
df_hh <- data.frame(HHID = sample(
x = 1:300,
size = 1000,
replace = TRUE
),
age_cat = ordered(sample(
x = c("18-24", "25-39", "40-64", "64-100"),
size = 1000,
replace = TRUE
)))
table_basicstats(df_hh, "HHID", "age_cat")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.