Learn R Programming

sumExtras (version 1.0.0)

use_jama_theme: Apply JAMA Compact Theme to gtsummary Tables

Description

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.

Usage

use_jama_theme(quiet = TRUE)

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.

Arguments

quiet

Logical. If FALSE, prints a message confirming theme application. Default is TRUE (silent).

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_compact for JAMA-style gt tables

  • extras for standard sumExtras table formatting

  • gtsummary::theme_gtsummary_compact() for other compact theme options

  • gtsummary::set_gtsummary_theme() for setting custom themes

  • gtsummary::reset_gtsummary_theme() for resetting to default theme

Examples

Run this code
# \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)

# Works with all gtsummary table types
lm(age ~ trt + grade, data = gtsummary::trial) |>
  gtsummary::tbl_regression()

# Combine with sumExtras styling functions
use_jama_theme()
gtsummary::trial |>
  gtsummary::tbl_summary(by = trt, include = c(age, marker, stage)) |>
  extras() |>
  add_group_styling()

# Reset to default theme if needed
gtsummary::reset_gtsummary_theme()
# }

Run the code above in your browser using DataLab