Skip to contents

Create multiple summary tables for different variable sets across waves

Usage

margot_make_tables(data, vars, waves, labels = NULL, show_progress = TRUE)

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)

Value

list of gtsummary tables

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