Wrapper function for rtables::add_combo_levels()
which configures settings for the risk difference
column to be added to an rtables
object. To add a risk difference column to a table, this function
should be used as split_fun
in calls to rtables::split_cols_by()
, followed by setting argument
riskdiff
to TRUE
in all following analyze function calls.
Arguments
- arm_x
(
character
)
Name of reference arm to use in risk difference calculations.- arm_y
(
character
)
Name of arm to compare to reference arm in risk difference calculations.- col_label
(
character
)
Label to use when rendering the risk difference column within the table.- pct
(
flag
)
whether output should be returned as percentages. Defaults toTRUE
.
Value
A closure suitable for use as a split function (split_fun
) within rtables::split_cols_by()
when creating a table layout.
See also
stat_propdiff_ci()
for details on risk difference calculation.
Examples
adae <- tern_ex_adae
adae$AESEV <- factor(adae$AESEV)
lyt <- basic_table() %>%
split_cols_by("ARMCD", split_fun = add_riskdiff(arm_x = "ARM A", arm_y = "ARM B")) %>%
count_occurrences_by_grade(
var = "AESEV",
riskdiff = TRUE
)
tbl <- build_table(lyt, df = adae)
tbl
#> ARM A ARM B ARM C Risk Difference (%) (95% CI)
#> ——————————————————————————————————————————————————————————————————————————————
#> MILD 6 (3.0%) 4 (2.3%) 2 (1.2%) 0.7 (-2.5 - 3.9)
#> MODERATE 19 (9.4%) 15 (8.5%) 14 (8.6%) 0.9 (-4.8 - 6.7)
#> SEVERE 34 (16.8%) 38 (21.5%) 32 (19.8%) -4.6 (-12.6 - 3.3)