Warnes, Gregory R
gregory_r_warnes@groton.pfizer.com
Wed, 18 Sep 2002 18:21:33 -0400
> -----Original Message-----
> From: Dr. Chris Wills [mailto:cwills@ucsd.edu]
>
> [...]
>
> 1) I cannot figure out how to sort one column in an array, and drag
> the rest of the values that occupy the other columns along with the
> sorted values in the first column. What I would like to end up with is
> an array that is the same size and dimensions as the first array. When
> I try various configurations of sort, I keep getting vectors instead of
> the array I started with, and I have not found a way to make sort
> "bind" other values to the sorted values.
Do this:
# example data matrix
datamat <- matrix(rnorm(1000),ncol=20)
ord <- order(x[,1])
sortmat <- datamat[ord,]
-Greg
LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._