This function replaces the counts in the default header of
gtsummary::tbl_svysummary()
tables to counts representing the
Effective Sample Size (ESS). See ess()
for details.
Arguments
- x
(
tbl_svysummary
)
Object of class'tbl_svysummary'
typically created withgtsummary::tbl_svysummary()
.- header
(
string
)
String specifying updated header. Reviewgtsummary::modify_header()
for details on use.
Examples
svy <- survey::svydesign(~1, data = nhefs_weights, weights = ~ w_ate)
gtsummary::tbl_svysummary(svy, include = c(age, sex, smokeyrs)) |>
add_ess_header()
Characteristic
Overall
ESS = 1013.31
Abbreviation: ESS = Effective Sample Size
1 Median (Q1, Q3); n (%)
hdr <- paste0(
"**{level}** \n",
"N = {n_unweighted}; ESS = {format(n, digits = 1, nsmall = 1)}"
)
gtsummary::tbl_svysummary(svy, by = qsmk, include = c(age, sex, smokeyrs)) |>
add_ess_header(header = hdr)
Characteristic
0
N = 1163; ESS = 1128.61
1
N = 403; ESS = 326.01
Abbreviation: ESS = Effective Sample Size
1 Median (Q1, Q3); n (%)