Skip to contents

Mark Use Day by Subject

Usage

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

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).

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).

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

   MarkUse(c("Crack", "Pcp", "Opioid"))
#> # A tibble: 29,587 × 3
#>      who  when source
#>    <int> <dbl> <fct> 
#>  1     2     0 UDS   
#>  2     2     7 UDS   
#>  3     2    97 UDS   
#>  4     3    -9 TFB   
#>  5     3   196 UDS   
#>  6     4   -47 TFB   
#>  7     4   -46 TFB   
#>  8     4   -45 TFB   
#>  9     4   -44 TFB   
#> 10     4   -43 TFB   
#> # ℹ 29,577 more rows