table_basicstats: Compute basic statistics of the number of members per group...

View source: R/table_basicstats.R

table_basicstatsR 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 df uniquely identifying households

group_by_var

string (length 1) to pass to group_by_at() with name of variable in df to group results by

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")

lindsayevanslee/whomds documentation built on Sept. 9, 2023, 10:54 p.m.