Toggles standard whitespace to non-breaking spaces (\u00A0) dynamically
in all visible statistics columns of a gtsummary table's body (or vice versa).
This forces the layout engine to keep statistics (e.g., "12.5 ( 95%)")
on a single line when protected. Column headers and labels remain unaffected.
For the rare cases when protecting creates ugly squashed label column
protection can be reversed using the same function.
adjust_stat_columns_wrap(tbl, mode = c("protect", "unprotect"))A modified gtsummary object.
tbl <- gtsummary::tbl_summary(
trial,
by = trt,
include = c(age, grade)
)
adjust_stat_columns_wrap(tbl, "protect")
Characteristic
Drug A
N = 981
Drug B
N = 1021
1 Median (Q1, Q3); n (%)