table_basicstats {whomds} | R Documentation |
Compute basic statistics of the number of members per group per household
Description
Compute basic statistics of the number of members per group per household
Usage
table_basicstats(df, hh_id, group_by_var)
Arguments
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 |
Value
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.
Note
Includes a call to tidyr::complete()
, which causes the function to be a bit slow.
See Also
Other table functions:
table_unweightedpctn()
,
table_weightedpct()
Examples
#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")
[Package whomds version 1.1.1 Index]