I have:
B <- matrix(c(1, 0, 0, 1, 1, 1),
nrow=3,
ncol=2)
and I want:
B
[,1] [,2]
[1,] TRUE TRUE
[2,] FALSE TRUE
[3,] FALSE TRUE
as.logical(B)gives a 1D vector. Is there an idiomatic way to do the matrix type conversion?
I'm currently doing the wordy:
boolVector <- as.logical(B)
m <- nrow(B)
n <- ncol(B)
m <- matrix(boolVector, m , n)
m