Create multiple summary tables for different variable sets across waves
Source:R/margot_make_tables.R
margot_make_tables.Rd
Create multiple summary tables for different variable sets across waves
Arguments
- data
data frame containing the longitudinal data
- vars
list of variable lists, named by table (e.g., list(baseline = c("age", "sex"), outcomes = c("health", "wellbeing")))
- waves
list of wave lists, named corresponding to vars (e.g., list(baseline = c(1,2), outcomes = c(2,3)))
- labels
named vector of variable labels (e.g., c("sdo" = "SDO", "born_nz" = "Born NZ"))
- show_progress
logical, whether to show a progress bar (default: TRUE)
Examples
# define variable labels
var_labels <- c(
"sdo" = "Social Dominance Orientation",
"born_nz" = "Born NZ",
"rural_gch_2018_l" = "Rural Gch 2018 Levels",
"eth_cat" = "Ethnicity",
"rwa" = "Right Wing Authoritarianism",
"support" = "Social Support (perceived)"
)
# create named lists of variables and waves
vars_list <- list(
baseline = c("age", "sex"),
outcomes = c("health", "wellbeing")
)
waves_list <- list(
baseline = c(1, 2),
outcomes = c(2, 3)
)
# create tables
summary_tables <- margot_make_tables(
data = dat_long_amelia,
vars = vars_list,
waves = waves_list,
labels = var_labels
)
#> Loading required package: gtsummary
#> Loading required package: janitor
#>
#> Attaching package: ‘janitor’
#> The following objects are masked from ‘package:stats’:
#>
#> chisq.test, fisher.test
#> Loading required package: labelled
#> Loading required package: stringr
#>
#> ── Margot Make Tables ──────────────────────────────────────────────────────────
#> Error: object 'dat_long_amelia' not found