DescTools (version 0.99.11)

IsDichotomous: Test If a Variable Contains Only Two Unique Values

Description

Test if a variable contains only two values, and maybe NAs. The variable does not need to be a numerical value, factors and logicals are supported as well.

Usage

IsDichotomous(x)

Arguments

x
a numeric or integer vector, a logical vector or a factor (ordered and unordered)

Value

  • TRUE if x contains only two unique values, FALSE else

Examples

Run this code
IsDichotomous(sample(10, 5, replace=TRUE))

Run the code above in your browser using DataCamp Workspace