# NOT RUN {
### Standard evaluation
data_process(
Rx_deliv = sample_Rx_unprocessed, Rx_id = "id", Rx_drug_code = "code",
Rx_drug_deliv = "start", Rx_deliv_dur = "duration",
cores = 1L
)
### Hospitalisation stays
rx1 <- data.frame(
id = c(1L, 3:8),
code = LETTERS[c(1, 3:8)],
date = as.Date(c("2001-01-15", "2003-03-15", "2004-04-15", "2005-05-15",
"2006-06-15", "2007-07-15", "2008-08-15")),
duration = 10L
)
hosp1 <- data.frame(
ID = 3:8,
ADM = as.Date(c("2003-03-10", "2004-04-25", "2005-05-12",
"2006-06-20", "2007-07-26", "2008-08-01")),
DEP = as.Date(c("2003-03-14", "2004-04-30", "2005-05-17",
"2006-06-30", "2007-07-30", "2008-08-13"))
)
data_process(
Rx_deliv = rx1, Rx_id = "id", Rx_drug_code = "code",
Rx_drug_deliv = "date", Rx_deliv_dur = "duration",
Hosp_stays = hosp1, Hosp_id = "ID", Hosp_admis = "ADM", Hosp_discharge = "DEP",
study_start = "2001-01-01", study_end = "2008-12-31",
cores = 1L
)
# Many drug codes
rx2 <- data.frame(
id = 1L,
code = c(111L, 222L, 222L, 333L, 444L),
date = as.Date(c("2001-01-15", "2002-02-15", "2002-03-01", "2004-04-07", "2004-05-05")),
duration = as.integer(c(10, 10, 10, 30, 10))
)
hosp2 <- data.frame(
id = 1L,
adm = as.Date(c("2000-01-01", "2000-01-15", "2001-01-01", "2002-02-23", "2004-04-15")),
dep = as.Date(c("2000-01-31", "2000-01-31", "2001-01-10", "2002-02-28", "2004-05-15"))
)
data_process(
Rx_deliv = rx2, Rx_id = "id", Rx_drug_code = "code",
Rx_drug_deliv = "date", Rx_deliv_dur = "duration",
Hosp_stays = hosp2, Hosp_id = "id", Hosp_admis = "adm", Hosp_discharge = "dep",
study_start = "2001-01-01", study_end = "2008-12-31",
cores = 1L
)
### Study dates - start and end
rx3 <- data.frame(id = 1:3,
code = "A",
date = as.Date(c("2020-01-01", "2020-06-06", "2020-12-22")),
duration = 10L)
# NULLs
data_process(Rx_deliv = rx3, Rx_id = "id", Rx_drug_code = "code",
Rx_drug_deliv = "date", Rx_deliv_dur = "duration",
study_start = NULL, study_end = NULL,
cores = 1)
# Not NULLs
data_process(Rx_deliv = rx3, Rx_id = "id", Rx_drug_code = "code",
Rx_drug_deliv = "date", Rx_deliv_dur = "duration",
study_start = "2020-06-10", study_end = NULL,
cores = 1)
data_process(Rx_deliv = rx3, Rx_id = "id", Rx_drug_code = "code",
Rx_drug_deliv = "date", Rx_deliv_dur = "duration",
study_start = NULL, study_end = "2020-06-10",
cores = 1)
data_process(Rx_deliv = rx3, Rx_id = "id", Rx_drug_code = "code",
Rx_drug_deliv = "date", Rx_deliv_dur = "duration",
study_start = "2020-01-05", study_end = "2020-12-25",
cores = 1)
### Grace factor
rx4 <- data.frame(id = c(rep(1, 3), rep(2, 3)),
code = "A",
date = as.Date(c("2000-01-01", "2000-01-17", "2000-01-31",
"2000-06-01", "2000-06-23", "2000-07-16")),
duration = as.integer(c(10, 10, 10, 15, 15, 15)))
# 50% of duration
data_process(Rx_deliv = rx4, Rx_id = "id", Rx_drug_code = "code",
Rx_drug_deliv = "date", Rx_deliv_dur = "duration",
grace_fctr = 0.5,
cores = 1)
# 0% of duration
data_process(Rx_deliv = rx4, Rx_id = "id", Rx_drug_code = "code",
Rx_drug_deliv = "date", Rx_deliv_dur = "duration",
grace_fctr = 0,
cores = 1)
### Grace constant
rx5 <- data.frame(id = 1,
code = "A",
date = as.Date(c("2000-01-01", "2000-01-14", "2000-01-25")),
duration = as.integer(c(10, 10, 6)))
# 2 days
data_process(Rx_deliv = rx5, Rx_id = "id", Rx_drug_code = "code",
Rx_drug_deliv = "date", Rx_deliv_dur = "duration",
grace_fctr = 0, grace_cst = 2,
cores = 1)
# 3 days
data_process(Rx_deliv = rx5, Rx_id = "id", Rx_drug_code = "code",
Rx_drug_deliv = "date", Rx_deliv_dur = "duration",
grace_fctr = 0, grace_cst = 3,
cores = 1)
### Max reserve
rx6 <- data.frame(id = as.integer(c(1, 1, 3, 3, 3, 5, 5)),
code = "A",
date = as.Date(c("2000-01-01", "2000-01-31",
"2000-03-03", "2000-03-15", "2000-03-30",
"2000-05-05", "2000-05-05")),
duration = as.integer(c(30, 30,
30, 30, 30,
90, 90)))
# 0 days
data_process(Rx_deliv = rx6, Rx_id = "id", Rx_drug_code = "code",
Rx_drug_deliv = "date", Rx_deliv_dur = "duration",
study_start = NULL, study_end = "2000-12-31",
grace_fctr = 0, grace_cst = 0,
max_reserve = 0,
cores = 1)
# 60 days
data_process(Rx_deliv = rx6, Rx_id = "id", Rx_drug_code = "code",
Rx_drug_deliv = "date", Rx_deliv_dur = "duration",
study_start = NULL, study_end = "2000-12-31",
grace_fctr = 0, grace_cst = 0,
max_reserve = 60,
cores = 1)
# Inf days
data_process(Rx_deliv = rx6, Rx_id = "id", Rx_drug_code = "code",
Rx_drug_deliv = "date", Rx_deliv_dur = "duration",
study_start = NULL, study_end = "2000-12-31",
grace_fctr = 0, grace_cst = 0,
max_reserve = NULL,
cores = 1)
### Combine Hospital stays and Grace factor
rx7 <- data.frame(id = c(1L, 1L, 1L, 2L),
code = "A",
date = c("2000-01-01", "2000-02-20", "2000-04-11", "2002-02-02"),
duration = as.integer(c(30, 30, 30, 15)))
hosp7 <- data.frame(id = 1L,
adm = c("2000-01-11", "2000-02-21"),
dep = c("2000-01-15", "2000-02-25"))
data_process(Rx_deliv = rx7, Rx_id = "id", Rx_drug_code = "code",
Rx_drug_deliv = "date", Rx_deliv_dur = "duration",
Hosp_stays = hosp7, Hosp_id = "id",
Hosp_admis = "adm", Hosp_discharge = "dep",
study_start = "2000-01-01", study_end = "2002-12-31",
grace_fctr = 0.5, grace_cst = 0, max_reserve = NULL,
cores = 1)
# }
Run the code above in your browser using DataLab