Skip to contents

This function checks whether any follow-up columns in a data frame contain a value of `2`, which would indicate that the patient is lost to follow-up. EMBRACE-II only

Usage

add_lost_to_fu(df, pattern = "followup_")

Arguments

df

A data frame or tibble containing follow-up columns.

pattern

A character string specifying the pattern to identify follow-up columns. Default is `"followup"`.

Value

A data frame with an additional logical column `is_lost_to_fu` indicating if the patient is lost to follow-up.

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>