The following themes are available to use within the gtsummary package.
Print theme elements with theme_gtsummary_journal(set_theme = FALSE) |> print().
Review the themes vignette
for details.
Usage
theme_gtsummary_journal(
journal = c("jama", "lancet", "nejm", "qjecon"),
set_theme = TRUE
)
theme_gtsummary_compact(set_theme = TRUE, font_size = NULL)
theme_gtsummary_printer(
print_engine = c("gt", "kable", "kable_extra", "flextable", "huxtable", "tibble"),
set_theme = TRUE
)
theme_gtsummary_language(
language = c("de", "en", "es", "fr", "gu", "hi", "is", "ja", "kr", "mr", "nl", "no",
"pt", "se", "zh-cn", "zh-tw"),
decimal.mark = NULL,
big.mark = NULL,
iqr.sep = NULL,
ci.sep = NULL,
set_theme = TRUE
)
theme_gtsummary_continuous2(
statistic = "{median} ({p25}, {p75})",
set_theme = TRUE
)
theme_gtsummary_mean_sd(set_theme = TRUE)
theme_gtsummary_eda(set_theme = TRUE)Arguments
- journal
String indicating the journal theme to follow. One of
c("jama", "lancet", "nejm", "qjecon"). Details below.- set_theme
(scalar
logical)
Logical indicating whether to set the theme. Default isTRUE. WhenFALSEthe named list of theme elements is returned invisibly- font_size
(scalar
numeric)
Numeric font size for compact theme. Default is 13 for gt tables, and 8 for all other output types- print_engine
String indicating the print method. Must be one of
"gt","kable","kable_extra","flextable","tibble"- language
(
string)
String indicating language. Must be one of"de"(German),"en"(English),"es"(Spanish),"fr"(French),"gu"(Gujarati),"hi"(Hindi),"is"(Icelandic),"ja"(Japanese),"kr"(Korean),"nl"(Dutch),"mr"(Marathi),"no"(Norwegian),"pt"(Portuguese),"se"(Swedish),"zh-cn"(Chinese Simplified),"zh-tw"(Chinese Traditional)If a language is missing a translation for a word or phrase, please feel free to reach out on GitHub with the translated text.
- decimal.mark
(
string)
The character to be used to indicate the numeric decimal point. Default is"."orgetOption("OutDec")- big.mark
(
string)
Character used between every 3 digits to separate hundreds/thousands/millions/etc. Default is",", except whendecimal.mark = ","when the default is a space.- iqr.sep
(
string)
String indicating separator for the default IQR intbl_summary(). Ifdecimal.mark=is NULL,iqr.sep=is", ". The comma separator, however, can look odd whendecimal.mark = ",". In this case the argument will default to an en dash- ci.sep
(
string)
String indicating separator for confidence intervals. Ifdecimal.mark=is NULL,ci.sep=is", ". The comma separator, however, can look odd whendecimal.mark = ",". In this case the argument will default to an en dash- statistic
Default statistic continuous variables
Themes
theme_gtsummary_journal(journal)"jama"The Journal of the American Medical AssociationRound large p-values to 2 decimal places; separate confidence intervals with
"ll to ul".tbl_summary()Doesn't show percent symbol; use em-dash to separate IQR; runadd_stat_label()tbl_regression()/tbl_uvregression()show coefficient and CI in same column
"lancet"The LancetUse mid-point as decimal separator; round large p-values to 2 decimal places; separate confidence intervals with
"ll to ul".tbl_summary()Doesn't show percent symbol; use em-dash to separate IQR
"nejm"The New England Journal of MedicineRound large p-values to 2 decimal places; separate confidence intervals with
"ll to ul".tbl_summary()Doesn't show percent symbol; use em-dash to separate IQR
"qjecon"The Quarterly Journal of Economicstbl_summary()all percentages rounded to one decimal placetbl_regression(),tbl_uvregression()add significance stars withadd_significance_stars(); hides CI and p-value from outputFor flextable and huxtable output, the coefficients' standard error is placed below. For gt, it is placed to the right.
theme_gtsummary_compact()tables printed with gt, flextable, kableExtra, or huxtable will be compact with smaller font size and reduced cell padding
theme_gtsummary_printer(print_engine)Use this theme to permanently change the default printer.
theme_gtsummary_continuous2()Set all continuous variables to summary type
"continuous2"by default
theme_gtsummary_mean_sd()Set default summary statistics to mean and standard deviation in
tbl_summary()Set default continuous tests in
add_p()to t-test and ANOVA
theme_gtsummary_eda()Set all continuous variables to summary type
"continuous2"by defaultIn
tbl_summary()show the median, mean, IQR, SD, and Range by default
Use reset_gtsummary_theme() to restore the default settings
Review the themes vignette to create your own themes.
Examples
# Setting JAMA theme for gtsummary
theme_gtsummary_journal("jama")
#> Setting theme "JAMA"
# Themes can be combined by including more than one
theme_gtsummary_compact()
#> Setting theme "Compact"
trial |>
select(age, grade, trt) |>
tbl_summary(by = trt) |>
as_gt()
Characteristic
Drug A
N = 98
Drug B
N = 102
# reset gtsummary themes
reset_gtsummary_theme()
