Converts various representations of yes/no (numeric, text, case-insensitive) to logical TRUE/FALSE values.

recode_yn(x)

Arguments

x

A vector of yes/no values (numeric or character).

Value

A logical vector, with NA for unrecognized values.

Examples

recode_yn(c(1, 2, "yes", "no", NA))
#> [1]  TRUE FALSE  TRUE FALSE    NA