Re: [R] Changing a logical matrix into a numeric matrix

2011-01-10 Thread djhurio
Nice solution :) Another one: m <- matrix(c(T,T,F,T),nr=2) m matrix(as.integer(m), dim(m)) - -- http://djhurio.wordpress.com/ http://twitter.com/djhurio http://www.linkedin.com/in/martinsliberts http://www.csb.gov.lv/ -- View this message in context: http://r.789695.n4.nabble.com/Chang

Re: [R] Changing a logical matrix into a numeric matrix

2011-01-10 Thread emj83
Thanks for everyone's suggestionsI didn't realise it was so straightforward- thanks for teaching me new tricks! Emma -- View this message in context: http://r.789695.n4.nabble.com/Changing-a-logical-matrix-into-a-numeric-matrix-tp3206797p3206844.html Sent from the R help mailing list archiv

Re: [R] Changing a logical matrix into a numeric matrix

2011-01-10 Thread baptiste auguie
Hi, Try this, mode(m) <- "integer" HTH, baptiste On 10 January 2011 10:17, emj83 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 > >

Re: [R] Changing a logical matrix into a numeric matrix

2011-01-10 Thread Ted Harding
On 10-Jan-11 09:17:26, emj83 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,]10 0 >

Re: [R] Changing a logical matrix into a numeric matrix

2011-01-10 Thread Joshua Wiley
Hi Emma, The easiest way I know uses a bit of a trick. If your matrix is named 'X' Then: X + 0 will convert it to numeric data. HTH, Josh On Jan 10, 2011, at 1:17, emj83 wrote: > > Hi, > > I would like to turn my TRUE/FALSE matrix into a 1/0 matrix (i.e. True=1 and > False=0) > > [,1

Re: [R] Changing a logical matrix into a numeric matrix

2011-01-10 Thread Søren Højsgaard
83 Sendt: 10. januar 2011 10:17 Til: r-help@r-project.org Emne: [R] Changing a logical matrix into a numeric matrix 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

[R] Changing a logical matrix into a numeric matrix

2011-01-10 Thread emj83
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,]10 0 [2,]11 0 [3,]11 1 Is there a quick wa