Coerces a vector to the strict 0/1 event coding required by
survival::survfit(). Dates (and POSIXct) map to 1 when present and 0
when missing, useful for free-text recurrence-date columns. Strings are
parsed against an explicit, anchored token list — no prefix matching.
Usage
.as_event01(x, mode = c("auto", "date_event", "death_event"))Details
This function deliberately differs from the legacy v5 implementation in
one place: "10 months" now returns NA, not 1. The original used
grepl("^1", x), which incorrectly classified any string starting with
1 as an event.
See also
Other helpers:
.add_year(),
.as_yesno(),
.find_col(),
.first_nonempty_col(),
.n_distinct_nonempty(),
.safe_date()