Determines whether a vector contains at most two distinct values.
See also
Other data.predicate:
flags(),
isEuclid(),
isLowCardinality(),
isNumeric(),
isWholeLike(),
isZero(),
nUnique()
Examples
isDichotomous(c(0, 1, 1))
#> [1] TRUE
isDichotomous(c(1, 1, 1))
#> [1] TRUE
isDichotomous(c(1, 1, 1), strict = TRUE)
#> [1] FALSE
isDichotomous(c(0, 1, NA)) # NA
#> [1] NA
isDichotomous(c(0, 1, NA), na.rm = TRUE)
#> [1] TRUE
isDichotomous(c("A", "A", "B"))
#> [1] TRUE
isDichotomous(c("A", "A", "B", "C"))
#> [1] FALSE
isDichotomous(factor(c("A", "A", "B", "C")))
#> [1] FALSE
