Adds labels describing the summary statistics presented for each variable in the tbl_summary / tbl_svysummary table.
add_stat_label(x, location = NULL, label = NULL)
x | Object with class |
---|---|
location | location where statistic label will be included.
|
label | a list of formulas or a single formula updating the statistic
label, e.g. |
A tbl_summary
or tbl_svysummary
object
Example 1
Example 2
Example 3
Other tbl_summary tools:
add_n.tbl_summary()
,
add_overall()
,
add_p.tbl_summary()
,
add_q()
,
bold_italicize_labels_levels
,
inline_text.tbl_summary()
,
inline_text.tbl_survfit()
,
modify
,
tbl_merge()
,
tbl_stack()
,
tbl_summary()
Other tbl_svysummary tools:
add_n.tbl_summary()
,
add_overall()
,
add_p.tbl_svysummary()
,
add_q()
,
modify
,
tbl_merge()
,
tbl_stack()
,
tbl_svysummary()
Daniel D. Sjoberg
tbl <- trial %>% dplyr::select(trt, age, grade, response) %>% tbl_summary(by = trt) # Example 1 ---------------------------------- # Add statistic presented to the variable label row add_stat_label_ex1 <- tbl %>% add_stat_label( # update default statistic label for continuous variables label = all_continuous() ~ "med. (iqr)" ) # Example 2 ---------------------------------- add_stat_label_ex2 <- tbl %>% add_stat_label( # add a new column with statistic labels location = "column" ) # Example 3 ---------------------------------- add_stat_label_ex3 <- trial %>% select(age, grade, trt) %>% tbl_summary( by = trt, type = all_continuous() ~ "continuous2", statistic = all_continuous() ~ c("{mean} ({sd})", "{min} - {max}"), ) %>% add_stat_label(label = age ~ c("Mean (SD)", "Min - Max"))