Additional themes for tables generated with gtsummary.
Usage
theme_gtsummary_prop_n(
prop_stat = "{p}% ({n})",
prop_digits = 1,
mean_sd = FALSE,
cont_digits = 1,
set_theme = TRUE
)
theme_gtsummary_fisher_simulate_p(set_theme = TRUE)
theme_gtsummary_unweighted_n(
n_unweighted_prefix = "",
n_unweighted_suffix = " obs.",
prop_digits = 1,
mean_sd = FALSE,
cont_digits = 1,
overall_string = NULL,
set_theme = TRUE
)
theme_gtsummary_bold_labels(set_theme = TRUE)Arguments
- prop_stat
(
character)
Statistics to display for categorical variables (seegtsummary::tbl_summary()).- prop_digits
(non-negative
integer)
Define the number of decimals to display for proportions.- mean_sd
(scalar
logical)
Also, set default summary statistics to mean and standard deviation ingtsummary::tbl_summary(). Default isFALSE.- cont_digits
(non-negative
integer)
Define the number of decimals to display for continuous variables.- set_theme
(scalar
logical)
Logical indicating whether to set the theme. Default isTRUE. WhenFALSEthe named list of theme elements is returned invisibly- n_unweighted_prefix, n_unweighted_suffix
(
character)
Prefix and suffix displayed before and after the unweighted number of observations.- overall_string
(
character)
Optional string to name the overall column.
Details
theme_gtsummary_prop_n() displays, by default, proportions before the
number of observations (between brackets). This function cannot be used
simultaneously with gtsummary::theme_gtsummary_mean_sd(), but you can use
the mean_sd = TRUE option of theme_gtsummary_prop_n().
theme_gtsummary_fisher_simulate_p() modify the default test used for
categorical variables by Fisher test, with computation of p-values by
Monte Carlo simulation in larger than 2×2 tables.
theme_gtsummary_unweighted_n() modifies default values of tables returned
by gtsummary::tbl_svysummary() and displays the unweighted number of
observations instead of the weighted n.
theme_gtsummary_bold_labels() applies automatically
gtsummary::bold_labels() to all tables generated with gtsummary.
Examples
# \donttest{
library(gtsummary)
trial |>
tbl_summary(include = c(grade, age), by = trt) |>
add_p()
Characteristic
Drug A
N = 981
Drug B
N = 1021
p-value2
1 n (%); Median (Q1, Q3)
2 Pearson’s Chi-squared test; Wilcoxon rank sum test
theme_gtsummary_prop_n(mean_sd = TRUE)
theme_gtsummary_fisher_simulate_p()
theme_gtsummary_bold_labels()
trial |>
tbl_summary(include = c(grade, age), by = trt) |>
add_p()
Characteristic
Drug A
N = 981
Drug B
N = 1021
p-value2
1 % (n); Mean (SD)
2 Fisher’s Exact Test for Count Data with simulated p-value
(based on 2000 replicates); Welch Two Sample t-test
# }
# \donttest{
data("api", package = "survey")
apistrat$both[1:5] <- NA
apistrat |>
srvyr::as_survey(strata = stype, weights = pw) |>
tbl_svysummary(include = c(stype, both), by = awards) |>
add_overall()
Characteristic
Overall
N = 6,1941
No
N = 2,2361
Yes
N = 3,9581
1 % (n)
theme_gtsummary_unweighted_n()
apistrat |>
srvyr::as_survey(strata = stype, weights = pw) |>
tbl_svysummary(include = c(stype, both), by = awards) |>
add_overall()
Characteristic
Overall
(200 obs.)1
No
(200 obs.)1
Yes
(200 obs.)1
1 % (n (unweighted) obs.)
# }
gtsummary::reset_gtsummary_theme()