uat_fixed_events: Use At Time Point, Fixed Range From Patient Event Date

Description Usage Arguments Value Examples

View source: R/use_at_time.R

Description

Determines which patients have been exposed to the drug(s) of interest within a timeframe of interest. This function applies the same timeframe to patient-specific event dates. By default it considers all prescriptions before or after the event date, but a number of days can be entered to give a more specific timeframe.

Usage

1
2
3
4
uat_fixed_events(df, df2, drug, flatten = FALSE, timeframe = 0,
  forward = TRUE, patient_id_col = "patient_id",
  drug_id_col = "drug_id", presc_date_col = "presc_date_x",
  ev_date_col = "ev_date_1", 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 dates - must contain at least patient IDs and an event date

drug

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

flatten

logical, if TRUE the function will only count one record/ prescription per drug ID per date

timeframe

a number representing the length of the follow-up window. If 0 as by default any prescriptions before or after (depending on the value of forward) the patient's event date, presc_date, will be considered

forward

a logical, if TRUE the value of timeframe will be added to the value of presc_date to generate an end date for the follow-up window. If FALSE, the value will be subtracted to generate a start date

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 the date the drug was prescribed

ev_date_col

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

date_format

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

Value

data frame containing a list of patient IDs for patients who have at least one prescription matching the criteria, the number of prescriptions within the defined date window and the date of the first matching prescription

Examples

1
2
3
uat_fixed_events(df = synth_presc, df2 = synth_events, drug = "SIMVASTATIN", forward = TRUE,
drug_id_col = "approved_name", presc_date_col = "presc_date", ev_date_col = "event_1",
date_format = "%Y-%m-%d")

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