Skip to content
Prev 30414 / 398513 Next

Transforming matrix

Assuming that TRUE==1 and FALSE==0, just do

 > x = matrix(c(TRUE,TRUE,FALSE,FALSE),2,2)
 > x
      [,1]  [,2]
[1,] TRUE FALSE
[2,] TRUE FALSE
 > as.numeric(x)
[1] 1 1 0 0
 > array(as.numeric(x),dim=dim(x))
      [,1] [,2]
[1,]    1    0
[2,]    1    0
Ramzi Feghali wrote: