This function examines follow-up status columns in a data frame to identify: 1. Patients lost to follow-up (indicated by a value of 2) 2. Patients who withdrew consent (indicated by a value of 3) EMBRACE-II study only.
Arguments
- df
A data frame or tibble containing follow-up columns with values: - 1: Normal follow-up - 2: Lost to follow-up - 3: Withdrew consent - NA: Missing data
- pattern
A character string specifying the pattern to identify follow-up columns. Default is "followup_". Columns must end with "m" (e.g., followup_3m, followup_6m).
Value
A data frame with two additional logical columns: - is_lost_to_fu: TRUE if patient was lost to follow-up - withdrew_consent: TRUE if patient withdrew consent
Examples
df <- tibble::tibble(
embrace_id = c("AAR2001", "VIE2001", "VIE2002"),
followup_3m = c(1, 1, 1),
followup_6m = c(1, 1, 1),
followup_9m = c(1, 1, 1),
followup_12m = c(1, -1, 1),
followup_18m = c(1, NA, 1),
followup_24m = c(NA, NA, -1)
)
add_lost_to_fu(df)
#> Looking for lost to FU and withdrew consent patients.
#> # A tibble: 3 × 9
#> embrace_id followup_3m followup_6m followup_9m followup_12m followup_18m
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 AAR2001 1 1 1 1 1
#> 2 VIE2001 1 1 1 -1 NA
#> 3 VIE2002 1 1 1 1 1
#> # ℹ 3 more variables: followup_24m <dbl>, is_lost_to_fu <lgl>,
#> # withdrew_consent <lgl>