presc_data_summary: Prescription dataset summary

Description Usage Arguments Value Examples

View source: R/summaries.R

Description

Function produces a high-level summary of a data frame, either the number of prescriptions and date of the first and last prescription for each patient or the total number of prescriptions and patients, the median and IQR prescriptions per patient and the dates of the first and last prescriptions across the data

Usage

1
2
3
presc_data_summary(df, drug = ".", summary = TRUE,
  patient_id_col = "patient_id", drug_id_col = "drug_id",
  presc_date_col = "presc_date_x", date_format)

Arguments

df

a data frame containing prescribing records to be analysed - records must contain at least a patient ID, a drug identifier and a prescription 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

summary

logical, if FALSE returns data on individual patients, if TRUE returns summary values

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 prescption date

date_format

a string, the format of the dates in df

Value

a data frame containing either a per patient summary of the data or a summary of the whole dataset, depending on the fvalue of summary

Examples

1
2
3
4
5
presc_data_summary(synth_presc, summary = FALSE, drug_id_col = "approved_name",
presc_date_col = "presc_date", date_format = "%Y-%m-%d")
presc_data_summary(synth_presc, drug = "SIMVASTATIN", summary = TRUE,
drug_id_col = "approved_name",
presc_date_col = "presc_date", date_format = "%Y-%m-%d")

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