Re: [R] Ordering data by variable

2010-09-03 Thread Joshua Wiley
On Thu, Sep 2, 2010 at 2:33 PM, Greg Snow wrote: > Suggestion:  use the power of R. > > If x and y are independent then sorting y based on x is meaningless. > > If sorting y based on x is meaningful, then they are not independent. > > Trying to force non-independent things to pretend that they are

Re: [R] Ordering data by variable

2010-09-02 Thread Greg Snow
Suggestion: use the power of R. If x and y are independent then sorting y based on x is meaningless. If sorting y based on x is meaningful, then they are not independent. Trying to force non-independent things to pretend that they are independent just causes future headaches. Part of the grea

Re: [R] Ordering data by variable

2010-09-02 Thread Joshua Wiley
Hi Marcio, Is this what you want? x <- c(2,6,8,8,1) y <- c(1,6,3,5,4) o <- order(x) # If you want each vector order by x x[o] y[o] You can also use sort(), but then each vector would be sorted by itself, not both by x. HTH, Josh On Thu, Sep 2, 2010 at 1:48 PM, Mestat wrote: > > Hi listers,