Similar to tbl_strata(), except the function accepts an ARD
instead of a data frame.
Usage
tbl_ard_strata(
cards,
strata,
.tbl_fun,
...,
.sep = ", ",
.combine_with = c("tbl_merge", "tbl_stack"),
.combine_args = NULL,
.header = ifelse(.combine_with == "tbl_merge", "**{strata}**", "{strata}")
)
tbl_ard_strata2(
cards,
strata,
.tbl_fun,
...,
.sep = ", ",
.combine_with = c("tbl_merge", "tbl_stack"),
.combine_args = NULL,
.header = ifelse(.combine_with == "tbl_merge", "**{strata}**", "{strata}")
)Arguments
- cards
(
card)
An ARD object of class"card"typically created withcards::ard_*()functions.- strata
(
tidy-select)
the grouping columns to stratify by. Must select'group#'and'group#_level'pairs. Importantly, the function expects the'group#'columns to be the same variable, e.g. stratifying by a single variable. The'group#_level'value is available to place in header (and more) via the{strata}element.- .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.- ...
Additional arguments passed on to the
.tbl_funfunction.- .sep
(
string)
when more than one stratifying variable is passed, this string is used to separate the levels in the spanning header. Default is", "- .combine_with
(
string)
One ofc("tbl_merge", "tbl_stack"). Names the function used to combine the stratified tables.- .combine_args
(named
list)
named list of arguments that are passed to function specified in.combine_with- .header
(
string)
String indicating the headers that will be placed. Default is"**{strata}**"when.combine_with = "tbl_merge"and"{strata}"when.combine_with = "tbl_stack". Items placed in curly brackets will be evaluated according toglue::glue()syntax.The evaluated value of
.headeris also available withintbl_strata2(.tbl_fun)
Examples
cards::ADLB |>
dplyr::filter(
AVISIT %in% c("Baseline", "Week 12", "Week 24"),
PARAMCD %in% c("ALB", "BUN")
) |>
cards::ard_summary(
strata = PARAM,
by = TRTA,
variables = AVAL
) |>
tbl_ard_strata2(
strata = c(group2, group2_level),
~ .x |>
tbl_ard_summary(by = TRTA, label = list(AVAL = .y)),
.combine_with = "tbl_stack",
.combine_args = list(group_header = NULL)
)
Characteristic
Placebo1
Xanomeline High Dose1
Xanomeline Low Dose1
1 Median (Q1, Q3)
