Sets the global gtsummary theme to the JAMA (Journal of the American Medical Association) compact style. Reduces padding and applies JAMA journal styling. The theme stays active for the entire R session or until changed with another theme.
Value
Invisibly returns the theme list object from
gtsummary::theme_gtsummary_compact("jama"). The theme is applied
globally via gtsummary::set_gtsummary_theme(), affecting all
subsequent gtsummary tables created in the session.
Details
The JAMA compact theme applies formatting standards from the Journal of the American Medical Association: 13px font, 1px cell padding, bold column headers, and clean borders.
The function checks for the gtsummary package and will stop with an
informative error if it is not installed. The theme is applied globally
and will affect all gtsummary tables created after calling this function,
including tbl_summary(), tbl_regression(),
tbl_cross(), tbl_strata(), and related functions.
For visual consistency with regular gt tables, use
theme_gt_compact() which replicates the same styling
for non-gtsummary tables.
See also
theme_gt_compactfor JAMA-style gt tablesextrasfor standard sumExtras table formattinggtsummary::theme_gtsummary_compact()for other compact theme optionsgtsummary::set_gtsummary_theme()for setting custom themesgtsummary::reset_gtsummary_theme()for resetting to default theme
Examples
# \donttest{
# Apply theme at the start of your analysis
use_jama_theme()
# All subsequent gtsummary tables will use JAMA formatting
gtsummary::trial |>
gtsummary::tbl_summary(by = trt)
Characteristic
Drug A
N = 981
Drug B
N = 1021
1 Median (Q1, Q3); n (%)
# Works with all gtsummary table types
lm(age ~ trt + grade, data = gtsummary::trial) |>
gtsummary::tbl_regression()
Characteristic
Beta
95% CI
p-value
Abbreviation: CI = Confidence Interval
# Combine with sumExtras styling functions
use_jama_theme()
gtsummary::trial |>
gtsummary::tbl_summary(by = trt, include = c(age, marker, stage)) |>
extras() |>
add_group_styling()
Overall
N = 2001
Drug A
N = 981
Drug B
N = 1021
p-value2
1 Median (Q1, Q3); n (%)
2 Wilcoxon rank sum test; Pearson’s Chi-squared test
# Reset to default theme if needed
gtsummary::reset_gtsummary_theme()
# }
