library(tibble)
library(dplyr, warn.conflicts = FALSE)
library(lubridate, warn.conflicts = FALSE)
advs <- tribble(
~USUBJID, ~ADT, ~TRTSDT, ~TRTEDT,
"P01", ymd("2020-02-24"), ymd("2020-01-01"), ymd("2020-03-01"),
"P02", ymd("2020-01-01"), ymd("2020-01-01"), ymd("2020-03-01"),
"P03", ymd("2019-12-31"), ymd("2020-01-01"), ymd("2020-03-01")
)
derive_var_ontrtfl(
advs,
start_date = ADT,
ref_start_date = TRTSDT,
ref_end_date = TRTEDT
)
advs <- tribble(
~USUBJID, ~ADT, ~TRTSDT, ~TRTEDT,
"P01", ymd("2020-07-01"), ymd("2020-01-01"), ymd("2020-03-01"),
"P02", ymd("2020-04-30"), ymd("2020-01-01"), ymd("2020-03-01"),
"P03", ymd("2020-03-15"), ymd("2020-01-01"), ymd("2020-03-01")
)
derive_var_ontrtfl(
advs,
start_date = ADT,
ref_start_date = TRTSDT,
ref_end_date = TRTEDT,
ref_end_window = 60
)
advs <- tribble(
~USUBJID, ~ADTM, ~TRTSDTM, ~TRTEDTM,
"P01", ymd_hm("2020-01-02T12:00"), ymd_hm("2020-01-01T12:00"), ymd_hm("2020-03-01T12:00"),
"P02", ymd("2020-01-01"), ymd_hm("2020-01-01T12:00"), ymd_hm("2020-03-01T12:00"),
"P03", ymd("2019-12-31"), ymd_hm("2020-01-01T12:00"), ymd_hm("2020-03-01T12:00"),
) %>%
mutate(TPT = c(NA, "PRE", NA))
derive_var_ontrtfl(
advs,
start_date = ADTM,
ref_start_date = TRTSDTM,
ref_end_date = TRTEDTM,
filter_pre_timepoint = TPT == "PRE"
)
advs <- tribble(
~USUBJID, ~ASTDT, ~TRTSDT, ~TRTEDT, ~AENDT,
"P01", ymd("2020-03-15"), ymd("2020-01-01"), ymd("2020-03-01"), ymd("2020-12-01"),
"P02", ymd("2019-04-30"), ymd("2020-01-01"), ymd("2020-03-01"), ymd("2020-03-15"),
"P03", ymd("2019-04-30"), ymd("2020-01-01"), ymd("2020-03-01"), NA,
)
derive_var_ontrtfl(
advs,
start_date = ASTDT,
end_date = AENDT,
ref_start_date = TRTSDT,
ref_end_date = TRTEDT,
ref_end_window = 60,
span_period = TRUE
)
advs <- tribble(
~USUBJID, ~ASTDT, ~AP01SDT, ~AP01EDT, ~AENDT,
"P01", ymd("2020-03-15"), ymd("2020-01-01"), ymd("2020-03-01"), ymd("2020-12-01"),
"P02", ymd("2019-04-30"), ymd("2020-01-01"), ymd("2020-03-01"), ymd("2020-03-15"),
"P03", ymd("2019-04-30"), ymd("2020-01-01"), ymd("2020-03-01"), NA,
)
derive_var_ontrtfl(
advs,
new_var = ONTR01FL,
start_date = ASTDT,
end_date = AENDT,
ref_start_date = AP01SDT,
ref_end_date = AP01EDT,
span_period = TRUE
)
Run the code above in your browser using DataLab