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

Stefan Fleck @te|@n@b@||eck @end|ng |rom gm@||@com
Sun Jan 30 10:16:44 CET 2022


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]]



More information about the R-help mailing list