Builds a data_ice data.frame from a column in the dataset that flags
intercurrent events. For each subject, the first visit (by factor level
order) where the flag is TRUE is used as the ICE visit.
Arguments
- data
A data.frame containing the analysis dataset.
- vars
A
varsobject as created byrbmi::set_vars().- ice_col
Character string naming the column in
datathat indicates ICE occurrence. Accepted values are logical (TRUE/FALSE), character ("Y"/"N"), or numeric (1/0).- strategy
Character string specifying the imputation strategy to assign. Must be one of
"MAR","CR","JR","CIR", or"LMCF".
Value
A data.frame with columns corresponding to vars$subjid,
vars$visit, and vars$strategy, suitable for passing to
rbmi::draws().
Examples
library(rbmi)
dat <- data.frame(
USUBJID = factor(rep(c("S1", "S2", "S3"), each = 3)),
AVISIT = factor(rep(c("Week 4", "Week 8", "Week 12"), 3),
levels = c("Week 4", "Week 8", "Week 12")),
TRT = factor(rep(c("Placebo", "Drug A", "Drug A"), each = 3)),
CHG = rnorm(9),
DISCFL = c("N","N","N", "N","Y","Y", "N","N","Y")
)
vars <- set_vars(
subjid = "USUBJID",
visit = "AVISIT",
group = "TRT",
outcome = "CHG"
)
ice <- prepare_data_ice(dat, vars, ice_col = "DISCFL", strategy = "JR")
print(ice)
#> USUBJID AVISIT strategy
#> 1 S2 Week 8 JR
#> 2 S3 Week 12 JR