# Create a custom check
chk_binary <- function(x) {
suppressWarnings(as.integer(x) %in% 0:1)
}
# Create custom expectation function
expect_binary <- expect_make(chk_binary)
# Validate a data frame
try(expect_binary(vs, data = mtcars))
try(expect_binary(cyl, data = mtcars))
Run the code above in your browser using DataLab