Function adapted from gtforester::tbl_subgroups().

tbl_roche_subgroups(data, rsp, by, subgroups, .tbl_fun)

Arguments

data

(data.frame, survey.design)
a data frame or survey object

rsp

(tidy-select)
Variable to use in responder rate calculations.

by

(tidy-select)
Variable to make comparison between groups.

subgroups

(tidy-select)
Variables to perform stratified analyses for.

.tbl_fun

(function) A function or formula. If a function, it is used as is. If a formula, e.g. ~ .x %>% tbl_summary() %>% add_p(), it is converted to a function. The stratified data frame is passed to this function.

Value

a 'gtsummary' table

Examples

if (FALSE) { # identical(Sys.getenv("NOT_CRAN"), "true")
tbl <-
  trial |>
  tbl_roche_subgroups(
    rsp = "response",
    by = "trt",
    subgroups = c("grade", "stage"),
    .tbl_fun =
      ~ glm(response ~ trt, data = .x) |>
        tbl_regression(
          show_single_row = trt,
          exponentiate = TRUE
        )
  )

tbl
}