This function generates the standard expression for pre-processing of dataset arm levels in and is used to apply the same steps in safety teal modules.
Arguments
- dataname
(
character
)
analysis data used in teal module.- parentname
(
character
)
parent analysis data used in teal module, usually this refers toADSL
.- arm_var
(
character
)
variable names that can be used asarm_var
.- drop_arm_levels
(
logical
)
whether to drop unused levels ofarm_var
. IfTRUE
,arm_var
levels are set to those used in thedataname
dataset. IfFALSE
,arm_var
levels are set to those used in theparentname
dataset. Ifdataname
andparentname
are the same, thendrop_arm_levels
is set toTRUE
and user input for this parameter is ignored.
Value
a {
object. See base::Paren()
for details.
Examples
prepare_arm_levels(
dataname = "adae",
parentname = "adsl",
arm_var = "ARMCD",
drop_arm_levels = TRUE
)
#> {
#> adae <- adae %>% dplyr::mutate(ARMCD = droplevels(ARMCD))
#> arm_levels <- levels(adae[["ARMCD"]])
#> adsl <- adsl %>% dplyr::filter(ARMCD %in% arm_levels)
#> adsl <- adsl %>% dplyr::mutate(ARMCD = droplevels(ARMCD))
#> }
prepare_arm_levels(
dataname = "adae",
parentname = "adsl",
arm_var = "ARMCD",
drop_arm_levels = FALSE
)
#> {
#> adsl <- adsl %>% dplyr::mutate(ARMCD = droplevels(ARMCD))
#> arm_levels <- levels(adsl[["ARMCD"]])
#> adae <- adae %>% dplyr::mutate(ARMCD = factor(ARMCD, levels = arm_levels))
#> }