# NOT RUN {
# Example 1 ----------------------------------
add_difference_ex1 <-
trial %>%
select(trt, age, marker) %>%
tbl_summary(by = trt,
statistic = all_continuous() ~ "{mean} ({sd})",
missing = "no") %>%
add_n() %>%
add_difference()
# Example 2 ----------------------------------
add_difference_ex2 <-
trial %>%
select(trt, response, death) %>%
tbl_summary(by = trt,
statistic = all_dichotomous() ~ "{p}%",
missing = "no") %>%
modify_footnote(all_stat_cols() ~ NA) %>%
add_n() %>%
add_difference(estimate_fun = ~paste0(style_sigfig(. * 100), "%"))
# }
Run the code above in your browser using DataCamp Workspace