is-dot-binary: Check if data structure has binary data in it

Description Usage Arguments Value Examples

Description

Check if a vector, data frame or matrix contains only binary (0,1) values.

Usage

1

Arguments

x

the input vector, data.frame or matrix

Value

boolean TRUE or FALSE

Examples

1
2
3
4
5
6
7
8
# works on vectors, matrices and data frames
is.binary(0)
is.binary(c(1, 0, 0, 1, 0))
is.binary(matrix(c(1,0), nrow=2, ncol=2))
is.binary(data.frame("a"=c(1,0), "b"=c(0,1)))

# returns FALSE if not binary
is.binary(c(1, 2, 3))

ddgraph documentation built on Nov. 17, 2017, 10:50 a.m.