# NOT RUN {
# With matches
rx1 <- data.frame(id = c(1, 1, 2, 2, 2), code = c("A", "B", "B", "C", "D"),
duration = as.integer(c(30, 15, 15, 7, 90)))
cst1 <- data.frame(CODES = c("B", "D"), DURATION = as.integer(c(45, 60)))
cst_deliv_duration(
Rx_deliv = rx1, Rx_drug_code = "code", Rx_deliv_dur = "duration",
Cst_deliv_dur = cst1, Cst_drug_code = "CODES", Cst_duration = "DURATION"
)
# No matches
rx2 <- data.frame(id = c(1, 1, 2, 2, 2), code = c("A", "B", "B", "C", "D"),
duration = as.integer(c(30, 15, 15, 7, 90)))
cst2 <- data.frame(CODES = c("E", "F"), DURATION = as.integer(c(45, 60)))
cst_deliv_duration(
Rx_deliv = rx2, Rx_drug_code = "code", Rx_deliv_dur = "duration",
Cst_deliv_dur = cst2, Cst_drug_code = "CODES", Cst_duration = "DURATION"
)
# }
Run the code above in your browser using DataLab