[R] [External] Weird behaviour of order() when having multiple ties

Richard M. Heiberger rmh @end|ng |rom temp|e@edu
Sun Jan 30 21:15:45 CET 2022


> x <- c(2,3,4,1,1,1,1,1)
> o.x <- order(x)
> o.x
[1] 4 5 6 7 8 1 2 3
> x[o.x]
[1] 1 1 1 1 1 2 3 4
> sort(x)
[1] 1 1 1 1 1 2 3 4
> 


order() is behaving correctly.

See ?order for details.


> On Jan 30, 2022, at 15:07, Stefan Fleck <stefan.b.fleck using gmail.com> wrote:
> 
> order(c(2,3,4,1,1,1,1,1))



More information about the R-help mailing list