new_users_var: Determine New vs. Ongoing Use of a Drug of Interest,...

Description Usage Arguments Value Examples

View source: R/use_at_time.R

Description

Classifies patients as new or ongoing users of the drug(s) of interest based on whether or not they have prescriptions within a set number of days of a patient-specific follow-up start date

Usage

1
2
3
4
new_users_var(df, df2, drug, timeframe = 0, return_all = 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 prescription records to be analysed - records must contain at least a patient ID, drug ID and prescription date

df2

a data frame containing dates to be used as patient specific start dates - needs to contain at least patient IDs and event dates

drug

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

timeframe

a number representing the length, in days, of the timeframe before the start date to check for previous prescriptions

return_all

a logical, if TRUE the function will return data for all patients as well as flags indicating if they were exposed during follow-up and if they are new users. If FALSE, returns only new users exposed during follow-up

patient_id_col

a string, the name of the column in df 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 prescription date

ev_date_col

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

date_format

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

Value

A data frame containing patient IDs, flags indicating if the patient was a new user at the start date and if they were exposed during follow-up, and where applicable the date of the first prescription during follow-up

Examples

1
2
3
4
new_users_var(synth_presc, df2 = synth_events,
drug = "SIMVASTATIN", timeframe = 90,
presc_date_col = "presc_date", drug_id_col = "approved_name",
ev_date_col = "start_date")

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