Uses dplyr::n_distinct() to check if there are only two unique values.
is_binary(x, na.rm = TRUE)A vector.
logical; Should NA be ignored, TRUE by default.
TRUE if only 2 unique values.
if (is_binary(x <- c("Yes", "No"))) x == "Yes"
#> [1] TRUE FALSE