Re: [R] order() with randomised order in ties?

2009-06-04 Thread Rainer M Krug
On Thu, Jun 4, 2009 at 12:45 PM, Rainer M Krug wrote: > On Thu, Jun 4, 2009 at 12:36 PM, Patrick Burns > wrote: >> How about: >> >> order(x, runif(length(x))) > > Thanks - that is really elegant. One thing: it is saver to use sample(length(x)) instead of runif(length(x)), as runif() might also

Re: [R] order() with randomised order in ties?

2009-06-04 Thread Rainer M Krug
On Thu, Jun 4, 2009 at 12:36 PM, Patrick Burns wrote: > How about: > > order(x, runif(length(x))) Thanks - that is really elegant. Rainer > > > > Patrick Burns > patr...@burns-stat.com > +44 (0)20 8525 0696 > http://www.burns-stat.com > (home of "The R Inferno" and "A Guide for the Unwilling S

Re: [R] order() with randomised order in ties?

2009-06-04 Thread Patrick Burns
How about: order(x, runif(length(x))) Patrick Burns patr...@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of "The R Inferno" and "A Guide for the Unwilling S User") Rainer M Krug wrote: Sorry for replying to my own post, but I found a solution. Still, a more elegant solu

Re: [R] order() with randomised order in ties?

2009-06-04 Thread Rainer M Krug
Sorry for replying to my own post, but I found a solution. Still, a more elegant solution would be preferred. On Thu, Jun 4, 2009 at 12:02 PM, Rainer M Krug wrote: > Hi > > I want to use order() to get the order of a vector. > > But I would need a different behavior when ties occur: similar to th

[R] order() with randomised order in ties?

2009-06-04 Thread Rainer M Krug
Hi I want to use order() to get the order of a vector. But I would need a different behavior when ties occur: similar to the parameter ties.method = "random" in the rank() function, I would need to randomise the ties. Is this possible? Example: x <- rep(1:10, 2) order(x) [1] 1 11 2 12 3 13