is_binary {campfin}R Documentation

Check if Binary

Description

Uses dplyr::n_distinct() to check if there are only two unique values.

Usage

is_binary(x, na.rm = TRUE)

Arguments

x

A vector.

na.rm

logical; Should NA be ignored, TRUE by default.

Value

TRUE if only 2 unique values.

Examples

if (is_binary(x <- c("Yes", "No"))) x == "Yes"

[Package campfin version 1.0.9 Index]