Skip to contents

Find the number of visits in the pattern until the last subject contact

Usage

measure_retention(use_pattern, missing_is = "o")

Arguments

use_pattern

A character string showing the daily, by visit, or weekly substance use pattern for a single subject

missing_is

Which single character is used to mark missing UDS in a use pattern string? Defaults to "o".

Value

An integer measuring the number of visits before the subject was lost to follow-up. If the subject's entire use pattern is missing, then this will be 0.

Details

At current, we allow for many symbols in the use pattern "word", such as "_" for missing by study design, "o" missing for protocol non-compliance (the most common form of missing), "+" for positive, "-" for negative, and "*" for mixed positive and negative results (this usually comes up when the visit represents multiple days and there are both positive and negative results in those days; for example, a subject is tested weekly; they provided a positive test on Tuesday but came back to provide a negative test the following day).

Examples

  pattern_char <- "__++++*o-------+--+-o-o-o+o+oooooo"
  measure_retention(pattern_char)
#> [1] 28
  
  pattern2_char <- "ooooooooooo"
  measure_retention(pattern2_char)
#> [1] 0