This function takes a vector and converts all instances of "yes" to 1, "no" to 0, and leaves other values as NA. It's useful for converting categorical "yes"/"no" responses into a numeric format that can be used in statistical analysis.
Examples
test_vector <- c("yes", "no", "maybe", "yes", "no")
tar_yes_no(test_vector)
#> [1] 1 0 NA 1 0
