Re: [R] Help with ordering values

2012-05-19 Thread Søren Højsgaard
Will y[order(match(y,x))] [1] 9 8 11 2 1 do? Regards Søren -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Lars Bishop Sent: 20. maj 2012 01:05 To: r-help@r-project.org Subject: [R] Help with ordering values Hi, Is it

[R] Help with ordering values

2012-05-19 Thread Lars Bishop
Hi, Is it possible to use x and y below to produce the vector shown in desired.result (which represents the values in y ordered according to the order specified by x)? Ideally the solution must be efficient in terms of timing as I'm dealing with *very* long vectors. x <- c(7, 6, 5, 9, 4, 14, 8,