[R] Changing a logical matrix into a numeric matrix

baptiste auguie baptiste.auguie at googlemail.com
Mon Jan 10 11:13:16 CET 2011


Hi,

Try this,

mode(m) <- "integer"

HTH,

baptiste

On 10 January 2011 10:17, emj83 <stp08emj at shef.ac.uk> wrote:
>
> Hi,
>
> I would like to turn my TRUE/FALSE matrix into a 1/0 matrix (i.e. True=1 and
> False=0)
>
>      [,1]  [,2]  [,3]
> [1,]  TRUE FALSE FALSE
> [2,]  TRUE  TRUE FALSE
> [3,]  TRUE  TRUE  TRUE
>
>      [,1]  [,2]  [,3]
> [1,]    1    0     0
> [2,]    1    1     0
> [3,]    1    1     1
>
> Is there a quick way of doing this without a loop?
>
> Thanks Emma
> --
> View this message in context: http://r.789695.n4.nabble.com/Changing-a-logical-matrix-into-a-numeric-matrix-tp3206797p3206797.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list