Learn R Programming

examly (version 0.2.0)

is_scored_01: Check if a vector is scored 0/1

Description

Detects if a vector (after removing NAs) contains only 0 and 1.

Usage

is_scored_01(vec)

Value

TRUE if the vector is 0/1 scored, FALSE otherwise.

Arguments

vec

The vector to check.

Examples

Run this code
is_scored_01(c(1, 0, 1, 0, NA))
is_scored_01(c(1, 0, 2, 0))
is_scored_01(c("A", "B", "C"))

Run the code above in your browser using DataLab