Skip to contents

Each theme_ltsummary_*() function builds a theme, activates it with set_ltsummary_theme() (unless set_theme = FALSE), and returns the element list invisibly. Clear the active theme with reset_ltsummary_theme().

  • theme_ltsummary_mean_sd(): continuous variables report "{mean} ({sd})", and add_p() defaults to "t.test" and "oneway.test" for them.

  • theme_ltsummary_continuous2(): continuous variables default to the multi-line "continuous2" type, with the statistics of the statistic argument.

  • theme_ltsummary_eda(): every continuous variable gets three lines, median with quartiles, mean with standard deviation, and the range, and percentages show one decimal place.

  • theme_ltsummary_compact(): tables render with a smaller font and less cell padding.

  • theme_ltsummary_journal(): the reporting conventions of a journal; see below.

  • theme_ltsummary_language(): the default labels, headers and footnotes are translated; see below.

Usage

theme_ltsummary_mean_sd(set_theme = TRUE)

theme_ltsummary_continuous2(
  statistic = "{median} ({p25}, {p75})",
  set_theme = TRUE
)

theme_ltsummary_eda(set_theme = TRUE)

theme_ltsummary_compact(set_theme = TRUE, font_size = NULL)

theme_ltsummary_journal(
  journal = c("jama", "lancet", "nejm", "qjecon"),
  set_theme = TRUE
)

theme_ltsummary_language(
  language = c("de", "en", "es", "fr", "gu", "hi", "is", "ja", "kr", "mr", "nl", "no",
    "pt", "se", "zh-cn", "zh-tw", "ba"),
  decimal.mark = NULL,
  big.mark = NULL,
  iqr.sep = NULL,
  ci.sep = NULL,
  set_theme = TRUE
)

Arguments

set_theme

(scalar logical)
Whether to activate the theme with set_ltsummary_theme(). Default is TRUE. With FALSE, the element list is returned (invisibly) without side effects.

statistic

(string)
The statistic string of continuous variables in theme_ltsummary_continuous2(). Default is "{median} ({p25}, {p75})".

font_size

(numeric)
Font size of the compact theme in pixels. Default is 13.

journal

(string)
One of "jama", "lancet", "nejm" and "qjecon".

language

(string)
One of "de" (German), "en" (English), "es" (Spanish), "fr" (French), "gu" (Gujarati), "hi" (Hindi), "is" (Icelandic), "ja" (Japanese), "kr" (Korean), "mr" (Marathi), "nl" (Dutch), "no" (Norwegian), "pt" (Portuguese), "se" (Swedish), "zh-cn" (Chinese Simplified), "zh-tw" (Chinese Traditional) and "ba" (Bosnian).

decimal.mark, big.mark

(string)
The marks passed to the style_*() formatters while the theme is active. Default is NULL, which leaves the marks unchanged.

iqr.sep, ci.sep

(string)
Separators of the interquartile range and of confidence intervals.

Value

A named list of theme elements, invisibly.

Journals

  • "jama", JAMA: p-values with two significant digits, the quartiles of the interquartile range separated by an en dash, percentages without the % sign, statistic labels on each row with the quartile label shortened to "IQR", and the estimate of tbl_regression() and add_difference() merged with its confidence interval into one column.

  • "nejm", New England Journal of Medicine: as JAMA, without the relocated statistic labels and merged columns.

  • "lancet", The Lancet: the interpunct as decimal mark, a space as big mark, and p-values rounded to the journal's rules.

  • "qjecon", The Quarterly Journal of Economics: percentages with one decimal place, and regression tables with the standard error under the estimate, significance stars from add_significance_stars() and no confidence interval column.

Languages

theme_ltsummary_language() translates the default headers, labels and footnotes ("Characteristic", "Median", "Unknown", the test names, ...) with the translation table of gtsummary 2.5.1. Text from your data, such as variable labels and factor levels, is not translated. decimal.mark and big.mark change the number formatting; iqr.sep and ci.sep change the separators of the interquartile range in tbl_summary() and of confidence intervals. When decimal.mark = "," is given, the separators default to an en dash so numbers stay unambiguous.

Examples

set_ltsummary_theme(theme_ltsummary_eda(set_theme = FALSE))
#> Setting theme "Exploratory Data Analysis"
tbl_summary(trial, include = c(age, grade))
reset_ltsummary_theme() with_ltsummary_theme( theme_ltsummary_language("es", set_theme = FALSE), tbl_summary(trial, by = trt, include = age) )