is.01: Check if a variable is 0/1 encoded

View source: R/is.01.r

is.01R Documentation

Check if a variable is 0/1 encoded

Description

Check if a variable is 0/1 encoded

Usage

is.01(x, na.rm = FALSE)

Arguments

x

a vector

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

Value

boolean

Author(s)

JuG

Examples

testDf <- data.frame(a = runif(10),
                    b = rbinom(10, size = 1, prob = .2),
                    c = as.Date(Sys.time())- 10:1,
                    d = factor(x = rep(3,10)),
                    e = NA,
                    f = rep(0,10),
                    g = rep(1,10),
                    h = sample(x = c(0,1,NA), size = 10, replace = T),
                    i = sample(x = c(0,NA), size = 10, replace = T),
                    j = sample(x = c(1,NA), size = 10, replace = T))
sapply(testDf, FUN=is.01)

jgodet/utilitR documentation built on May 16, 2024, 12:01 p.m.