[R] Weird behaviour of order() when having multiple ties
Jeff Newmiller
jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Sun Jan 30 22:14:06 CET 2022
Why should 6,5 be more correct than 5,6? How is R supposed to reach that conclusion based on comparing values?
On January 30, 2022 1:16:44 AM PST, Stefan Fleck <stefan.b.fleck using gmail.com> wrote:
>I am experiencing a weird behavior of `order()` for numeric vectors. I
>tested on 3.6.2 and 4.1.2 for windows and R 4.0.2 on ubuntu. Can anyone
>confirm?
>
>order(
> c(
> 0.6,
> 0.5,
> 0.3,
> 0.2,
> 0.1,
> 0.1
> )
>)
>## Result [should be in order]
>[1] 5 6 4 3 2 1
>
>The sort order is obviously wrong. This only occurs if i have multiple
>ties. The problem does _not_ occur for decreasing = TRUE.
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
--
Sent from my phone. Please excuse my brevity.
More information about the R-help
mailing list