set_gtsummary_theme: Set a gtsummary theme

View source: R/set_gtsummary_theme.R

set_gtsummary_themeR Documentation

Set a gtsummary theme

Description

\lifecycle

maturing Functions to set, reset, get, and evaluate with gtsummary themes.

  • set_gtsummary_theme() set a theme

  • reset_gtsummary_theme() reset themes

  • get_gtsummary_theme() get a named list with all active theme elements

  • with_gtsummary_theme() evaluate an expression with a theme temporarily set

  • check_gtsummary_theme() checks if passed theme is valid

Usage

set_gtsummary_theme(x, quiet = NULL)

reset_gtsummary_theme()

get_gtsummary_theme()

with_gtsummary_theme(
  x,
  expr,
  env = rlang::caller_env(),
  msg_ignored_elements = NULL
)

check_gtsummary_theme(x)

Arguments

x

A named list defining a gtsummary theme.

quiet

Logical indicating whether to print messages in console. Default is FALSE

expr

Expression to be evaluated with the theme specified in x= loaded

env

The environment in which to evaluate expr=

msg_ignored_elements

Default is NULL with no message printed. Pass a string that will be printed with cli::cli_alert_info(). The "{elements}" object contains vector of theme elements that will be overwritten and ignored.

Details

The default formatting and styling throughout the gtsummary package are taken from the published reporting guidelines of the top four urology journals: European Urology, The Journal of Urology, Urology and the British Journal of Urology International. Use this function to change the default reporting style to match another journal, or your own personal style.

Example Output

Example

See Also

Themes vignette

Available gtsummary themes

Examples

# Setting JAMA theme for gtsummary
set_gtsummary_theme(theme_gtsummary_journal("jama"))
# Themes can be combined by including more than one
set_gtsummary_theme(theme_gtsummary_compact())

set_gtsummary_theme_ex1 <-
  trial %>%
  dplyr::select(age, grade, trt) %>%
  tbl_summary(by = trt) %>%
  add_stat_label() %>%
  as_gt()

# reset gtsummary theme
reset_gtsummary_theme()

gtsummary documentation built on June 22, 2022, 9:07 a.m.