# \donttest{
# Example 1 ----------------------------------
add_difference_ex1 <-
trial %>%
select(trt, age, marker, response, death) %>%
tbl_summary(
by = trt,
statistic =
list(
all_continuous() ~ "{mean} ({sd})",
all_dichotomous() ~ "{p}%"
),
missing = "no"
) %>%
add_n() %>%
add_difference()
# Example 2 ----------------------------------
# ANCOVA adjusted for grade and stage
add_difference_ex2 <-
trial %>%
select(trt, age, marker, grade, stage) %>%
tbl_summary(
by = trt,
statistic = list(all_continuous() ~ "{mean} ({sd})"),
missing = "no",
include = c(age, marker, trt)
) %>%
add_n() %>%
add_difference(adj.vars = c(grade, stage))
# }
Run the code above in your browser using DataLab