library(tibble)
library(stringr)
advs <- tribble(
~USUBJID, ~VSDTC, ~VSTPT,
"1", "2020-04-16", NA_character_,
"1", "2020-04-16", "BEFORE TREATMENT"
)
# For the second slice filter is set to TRUE. Thus derive_vars_dtm is called
# with time_imputation = "last" for all observations which do not match for the
# first slice.
slice_derivation(
advs,
derivation = derive_vars_dtm,
args = params(
dtc = VSDTC,
new_vars_prefix = "A"
),
derivation_slice(
filter = str_detect(VSTPT, "PRE|BEFORE"),
args = params(time_imputation = "first")
),
derivation_slice(
filter = TRUE,
args = params(time_imputation = "last")
)
)
Run the code above in your browser using DataLab