library(tibble)
library(lubridate)
library(dplyr, warn.conflicts = FALSE)
datain <- tribble(
~TRTSDTM, ~ASTDTM, ~AENDT,
"2014-01-17T23:59:59", "2014-01-18T13:09:O9", "2014-01-20"
) %>%
mutate(
TRTSDTM = as_datetime(TRTSDTM),
ASTDTM = as_datetime(ASTDTM),
AENDT = ymd(AENDT)
)
derive_vars_dy(
datain,
reference_date = TRTSDTM,
source_vars = exprs(TRTSDTM, ASTDTM, AENDT)
)
# specifying name of new variables
datain <- tribble(
~TRTSDT, ~DTHDT,
"2014-01-17", "2014-02-01"
) %>%
mutate(
TRTSDT = ymd(TRTSDT),
DTHDT = ymd(DTHDT)
)
derive_vars_dy(
datain,
reference_date = TRTSDT,
source_vars = exprs(TRTSDT, DEATHDY = DTHDT)
)
Run the code above in your browser using DataLab