Generates standard epidemiological Table 1 descriptive statistics and Table 1b completeness audit.
Usage
generate_table1(
data,
strata_col = "outcome_flag",
continuous_vars = NULL,
categorical_vars = NULL,
table_name = NULL,
strata_labels = NULL,
compute_smd = TRUE,
compute_pvalues = TRUE,
decimal_places = 1,
groups = NULL
)Arguments
- data
A
data.frameor active DuckDB DBI connection.- strata_col
Column name defining stratification (default "outcome_flag").
- continuous_vars
Character vector of continuous column names.
- categorical_vars
Character vector of categorical column names.
- table_name
Character string of table name if
datais a DuckDB connection.- strata_labels
Named list mapping strata values to display names.
- compute_smd
Logical. Compute Standardized Mean Differences between strata (default TRUE).
- compute_pvalues
Logical. Compute p-values between strata (default TRUE).
- decimal_places
Decimal places for numeric outputs: one integer for every variable, or a named vector / list
c(lab_creatinine = 2, age = 1)per variable. Variables not named use thedefaultentry, else 1. Percentages of a categorical variable follow that variable's setting; the header row uses the default.- groups
Optional named list
list("Demographics" = c("age", "female"), ...). Variables are ordered by section, each preceded by a header row (Variable= the title, other cells blank); variables not listed follow under "Other". Unknown names are ignored and a variable listed twice stays in its first section.
