[R] Transforming matrix
Sundar Dorai-Raj
sundar.dorai-raj at pdf.com
Thu Apr 10 16:17:06 CEST 2003
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
>
More information about the R-help
mailing list