# \donttest{
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"))
# }
Run the code above in your browser using DataLab