Recodes a set of columns so that values in ones become 1, values in
zeros become 0, and values in na_values become NA.
Usage
recode_binary(data, vars, ones = c(1, 2), zeros = 0, na_values = 98)Examples
d <- data.frame(x = c(0, 1, 2, 98))
recode_binary(d, "x")
#> x
#> 1 0
#> 2 1
#> 3 1
#> 4 NA