# ============================================================
# Table 1 with gtsummary
# Biostatistics in R — Rverse Analytics
# https://rverseanalytics.com/learn-biostatistics/table1
# ============================================================

# Table 1 with gtsummary - baseline characteristics
library(gtsummary)
library(dplyr)
# Summarise the trial cohort by treatment arm, with a p-value
trial |>
select(trt, age, grade, stage, marker) |>
tbl_summary(by = trt, missing_text = "(missing)") |>
add_p()
# Add labels, an overall column, and bold row labels
trial |>
select(trt, age, grade, stage, marker) |>
tbl_summary(by = trt,
label = list(age ~ "Age (years)", marker ~ "Marker (ng/mL)")) |>
add_p() |>
add_overall() |>
bold_labels()
