cst_deliv_duration: Constant delivery duration drugs

Description Usage Arguments Value Examples

View source: R/cst_deliv_duration.R

Description

Overwrites the recorded delivery durations of specific drugs with constant durations as specified in a user-provided table.

Usage

1
2
3
4
5
6
7
8
cst_deliv_duration(
  Rx_deliv,
  Rx_drug_code,
  Rx_deliv_dur,
  Cst_deliv_dur,
  Cst_drug_code,
  Cst_duration
)

Arguments

Rx_deliv

Name of the table listing all prescription drugs delivered.

Rx_drug_code

Column name of Rx_deliv that contains the drug unique identifier.

Rx_deliv_dur

Column name of the constant treatment duration in the Rx_deliv table.

Cst_deliv_dur

Name of the table that contains the constant delivery durations that will overwrite that in the Rx_deliv table for the specified drug codes.

Cst_drug_code

Column name of Cst_deliv_dur that contains the drug unique identifier (same format as Rx_drug_code).

Cst_duration

Column name of the constant treatment duration in the Cst_deliv_dur table (same format as Rx_deliv_dur).

Value

data.table of the same structure as Rx_deliv.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# 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"
)

polypharmacy documentation built on July 12, 2021, 5:08 p.m.