uat_windows: Use Windows Consecutive Time Windows

Description Usage Arguments Value Examples

View source: R/use_at_time.R

Description

Function divides follow-up time into evenly sized windows of a user-defined length and defines patient exposure to the drug(s) of interest based on the presence or absence of prescriptions within the windows

Usage

1
2
3
4
5
uat_windows(df, df2, drug, individual = FALSE, timeframe,
  return_all = FALSE, patient_id_col = "patient_id",
  drug_id_col = "drug_id", presc_date_col = "presc_date_x",
  ev_date_1_col = "ev_date_1", ev_date_2_col = "ev_date_2",
  date_format)

Arguments

df

a data frame containing prescribing records to be analysed - records must contain at least a patient ID, drug ID, prescription date

df2

a data frame containing event data to be analysed, records must contain at least two event dates (ev_date_1 and ev_date_2) representing the start and end dates of follow-up for each patient

drug

a string containing a drug ID to be used to limit the prescribing data to the drug(s) of interest, accepts regular expressions

individual

logical - if TRUE prescriptions are split into windows based on individual values of ev_date_1 and ev_date_2. If FALSE, prescriptions are split into the same windows across all patients, based on the maximum value of ev_date_1 and the minimum value of ev_date_2

timeframe

a number representing the desired length of each window in days

return_all

logical - if TRUE, all prescription windows are returned for all patients including windows where the patient did not have any prescriptions for the drug(s) of interest. If FALSE, only windows where patients had at least 1 prescription are returned

patient_id_col

a string, the name of the column in df and df2 containing the patient IDs

drug_id_col

a string, the name of the column in df containing the drug IDs

presc_date_col

a string, the name of the column in df containing

ev_date_1_col

a string, the name of the column in df2 containing the start of follow-up dates

ev_date_2_col

a string, the name of the column in df2 containing the second event dates if present

date_format

a string, the format of the dates contained in df and df2

Value

A data frame containing a sequence of date groups for each patient and the number of prescriptions the patient had during each window; if return_all is TRUE a flag indicates windows during which the patient was exposed (exposed = 1) and unexposed (exposed = 0)

Examples

1
2
3
4
5
uat_windows(df = synth_presc, df2 = synth_events, drug = "SIMVASTATIN",
individual = TRUE, timeframe = 90, return_all = TRUE,
patient_id_col = "patient_id", drug_id_col = "approved_name",
presc_date_col = "presc_date",
ev_date_1_col = "event_1", ev_date_2_col = "event_2", date_format = "%Y-%m-%d")

amarshall1/prescribeR documentation built on May 20, 2020, 2:34 p.m.