Operationalizes outcomes of type yes/no to binary variables. It is internally given the values to count as a "Yes" by regular expression, e.g. not only "Yes" but also "Support" and "For"

yesno_to_binary(vec, DK_to_NA = TRUE)

Arguments

vec

A vector of CCES response values, in character

DK_to_NA

Whether don't knows should be treated as NA. Defaults to TRUE.

Value

A vector of integers

Examples

yesno_to_binary( c("Yes", "No", "Support", "Oppose", "Somewhat support", "Somewhat oppose", "For this bill", "Against this bill", "Not sure", "Don't Know", NA_character_) )
#> [1] 1 0 1 0 1 0 1 0 NA NA NA