Description Usage Arguments Value Examples
Test if a matrix is a binary matrix (i.e. contains only 0s and 1s, and possibly NA). Adapted from https://stackoverflow.com/a/23276062
1 | isBinaryMat(mat)
|
mat |
A matrix. If mat is a data frame it will be converted by data.matrix with a warning. |
A logical. TRUE if the matrix is binary, FALSE otherwise
1 2 3 4 5 6 7 | set.seed(123)
x <- matrix(rnorm(100), ncol= 10) # not a binary matrix
y <- matrix(sample(0:1, 100, rep=TRUE), ncol=10) # a binary matrix
z <- y ; z[x>1.5] <- NA #a binary matrix with some NA
isBinaryMat(x) #FALSE
isBinaryMat(y) #TRUE
isBinaryMat(z) #TRUE
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.