Chapter 6 Baseline Table
A Table 1 summarising baseline characteristics stratified by case/control status is standard in epidemiological papers. UKBAnalytica wraps the tableone package for this purpose.
6.1 Basic usage
library(UKBAnalytica)
library(data.table)
# Assume `analysis_dt` was produced by build_survival_dataset()
table1 <- create_baseline_table(
data = analysis_dt,
case_col = "outcome_status",
factor_cols = c(
"sex", "smoking", "drinking",
"ethnicity", "education"
),
continuous_cols = c(
"age", "bmi", "sbp", "dbp",
"ldl", "hdl", "hba1c"
),
test = TRUE
)
print(table1, smd = TRUE)6.2 Exporting to CSV
The tableone print method returns a character matrix that can be written
directly to CSV: