i am sure that there is a simple solution that i am just overlooking, but there is no logical test for there is one for != and >,<, >=, <=... what do i do if i need to check if something IS EQUAL or is there an easy way, in working with a matrix of size n x 3, to sort the matrix by one of the columns? specifically what i am trying to do is i have a matrix with individual and group labels that is randomly generated, and is by default sorted by the individual labels ( column 1) and i want them to be organized into unique group labels (comlumn 2) thanks jimi jimi adams Department of Sociology The Ohio State University 300 Bricker Hall 190 N. Oval Mall Columbus, OH 43210-1353 614-688-4261 our mind has a remarkable ability to think of contents as being independent of the act of thinking -georg simmel -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
jimi adams <adams.644 at osu.edu> writes:> i am sure that there is a simple solution that i am just overlooking, > but there is no logical test for > there is one for != and >,<, >=, <=... > what do i do if i need to check if something IS EQUALDouble it: => or is there an easy way, in working with a matrix of size n x 3, to > sort the matrix by one of the columns? > > specifically what i am trying to do is i have a matrix with individual > and group labels that is randomly generated, and is by default sorted > by the individual labels ( column 1) and i want them to be organized > into unique group labels (comlumn 2) > thanksm[order(m[,2]),] -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Mon, 25 Feb 2002, jimi adams wrote:> i am sure that there is a simple solution that i am just overlooking, but > there is no logical test for > there is one for != and >,<, >=, <=... > what do i do if i need to check if something IS EQUALDepends. To test if two objects are the same, you can use identical(). Or you might use == in other situations. It's hard to know without more details.> or is there an easy way, in working with a matrix of size n x 3, to sort > the matrix by one of the columns?If m is an n x 3 matrix, to sort by column 1, you could do:> m.sorted <- m[order(m[,1]), ]-roger _______________________________ UCLA Department of Statistics rpeng at stat.ucla.edu http://www.stat.ucla.edu/~rpeng> > > specifically what i am trying to do is i have a matrix with individual and > group labels that is randomly generated, and is by default sorted by the > individual labels ( column 1) and i want them to be organized into unique > group labels (comlumn 2) > thanks > jimi > jimi adams > Department of Sociology > The Ohio State University > 300 Bricker Hall > 190 N. Oval Mall > Columbus, OH 43210-1353 > 614-688-4261 > > our mind has a remarkable ability to think of contents as being independent > of the act of thinking > -georg simmel > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
It's == if I'm understanding your question right. ---------------------------------------------------------------------- Andrew J Perrin - andrew_perrin at unc.edu - http://www.unc.edu/~aperrin Assistant Professor of Sociology, U of North Carolina, Chapel Hill 269 Hamilton Hall, CB#3210, Chapel Hill, NC 27599-3210 USA On Mon, 25 Feb 2002, jimi adams wrote:> i am sure that there is a simple solution that i am just overlooking, but > there is no logical test for > there is one for != and >,<, >=, <=... > what do i do if i need to check if something IS EQUAL > > or is there an easy way, in working with a matrix of size n x 3, to sort > the matrix by one of the columns? > > specifically what i am trying to do is i have a matrix with individual and > group labels that is randomly generated, and is by default sorted by the > individual labels ( column 1) and i want them to be organized into unique > group labels (comlumn 2) > thanks > jimi > jimi adams > Department of Sociology > The Ohio State University > 300 Bricker Hall > 190 N. Oval Mall > Columbus, OH 43210-1353 > 614-688-4261 > > our mind has a remarkable ability to think of contents as being independent > of the act of thinking > -georg simmel > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Use == to test for equality (like in C).> -----Original Message----- > From: jimi adams [SMTP:adams.644 at osu.edu] > Sent: Monday, February 25, 2002 12:06 PM > To: r-help at stat.math.ethz.ch > Subject: [R] another basic ? > > i am sure that there is a simple solution that i am just overlooking, but > there is no logical test for > there is one for != and >,<, >=, <=... > what do i do if i need to check if something IS EQUAL > > or is there an easy way, in working with a matrix of size n x 3, to sort > the matrix by one of the columns? > > specifically what i am trying to do is i have a matrix with individual and > > group labels that is randomly generated, and is by default sorted by the > individual labels ( column 1) and i want them to be organized into unique > group labels (comlumn 2) > thanks > jimi > jimi adams > Department of Sociology > The Ohio State University > 300 Bricker Hall > 190 N. Oval Mall > Columbus, OH 43210-1353 > 614-688-4261 > > our mind has a remarkable ability to think of contents as being > independent > of the act of thinking > -georg simmel > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. > -.-.- > r-help mailing list -- Read > http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. > _._._-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
jimi adams <adams.644 at osu.edu> writes:>i am sure that there is a simple solution that i am just overlooking, but >there is no logical test for >there is one for != and >,<, >=, <=... >what do i do if i need to check if something IS EQUAL==> or is there an easy way, in working with a matrix of size n x 3, to sort > the matrix by one of the columns?Use order() with the column (or row) indices: my.matrix[order(my.matrix[,column.to.sort.on]), ] As in: > my.matrix <- matrix(c(5:1, 6:8, 12:9), nrow = 4) > my.matrix [,1] [,2] [,3] [1,] 5 1 12 [2,] 4 6 11 [3,] 3 7 10 [4,] 2 8 9 > my.sorted.matrix <- my.matrix[order(my.matrix[ ,1]), ] > my.sorted.matrix [,1] [,2] [,3] [1,] 2 8 9 [2,] 3 7 10 [3,] 4 6 11 [4,] 5 1 12 Best wishes, Mark -- Mark Myatt -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._