Skip to content
Back to formatted view

Raw Message

Message-ID: <3E957CE2.6060807@pdf.com>
Date: 2003-04-10T14:17:06Z
From: Sundar Dorai-Raj
Subject: 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:
> hi everybody, 
> anyone knows how we can transform a binary matrix with TRUE and FALSE to 0 and 1 without looping? 
> Thx 
> 
> 
> 
> ---------------------------------
> 
> 
> 	[[alternate HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>