# NOT RUN {
add_p_ex1 <-
trial %>%
dplyr::select(age, grade, response, trt) %>%
tbl_summary(by = trt) %>%
add_p()
# Conduct a custom McNemar test for response,
# The custom function must return a single p-value, or NA
add_p_test.mcnemar <- function(data, variable, by, ...) {
stats::mcnemar.test(data[[variable]], data[[by]])$p.value
}
add_p_ex2 <-
trial %>%
dplyr::select(response, trt) %>%
tbl_summary(by = trt) %>%
add_p(test = vars(response) ~ "mcnemar")
# }
Run the code above in your browser using DataLab