Learn R Programming

public.ctn0094extra (version 1.0.4)

MarkUse: Mark Use Day by Subject

Description

Mark Use Day by Subject

Usage

MarkUse(
  targetDrugs_char,
  drugs_df = NULL,
  reportSource = c("TFB", "UDSAB", "UDS"),
  retainEmptyRows = FALSE
)

Value

A modification of the drugs_df data set: the columns are "who", "when", and "source"; each row corresponds to one use day per subject per use source (if, for instance, there is drug use for a particular day recorded in both TFB and UDS, then that day will have two rows in the resulting data set).

Arguments

targetDrugs_char

A character vector including which drugs should be counted against the subject

drugs_df

A data frame with columns who, when, and what. This data frame measures which drugs were used by each subject over all days of treatment. This data set must also include a column source, which marks from which reporting source the drug use was recorded

reportSource

A character vector matching the source of the reported drug use. The options must be from Timeline Followback ("TFB") questionnaires or daily urine drug screens ("UDS" or"UDSAB").

retainEmptyRows

A logical flag to force rows for participants who did not have UDS positive for the substances listed in targetDrugs_char to be retained in the final results (with NA for "when" and "source"). Defaults to FALSE because the entire point of this function is to mark substance USE, not a lack thereof; however, this flag is needed for the vignette (because we forced the inclusion of a participant with no recorded UDS for pedagogical purposes).

Details

This function is basically just a fancy wrapper around some dplyr code. We just don't want the user to have to 1) know dplyr, or 2) write the code themselves.

Examples

Run this code
   MarkUse(c("Crack", "Pcp", "Opioid"))

Run the code above in your browser using DataLab