0

It looks like "order" function is not working properly with repeated values. For example, check the code below. As you can see, same elemets have a different order.

Is there any way to fix this?

special <- c(0.8612482, 0.1728704, 0.1728704, 0.6933106, 0.4718281, 0.4718281, 0.8275597,
                 0.3934772, 0.3934772, 0.6777266, 0.2526969, 0.0605038, 0.7352600, 0.7352600,
                 2.2376845, 0.8814698, 2.7420961, 2.7420961, 1.5314565, 1.4855230)
special[8]
order(special)[8]

special[9]
order(special)[9]

1 Answers1

1

I think the function you are looking for is sort() not order().

sort(special)[8]
0.4718281

sort():

Sort (or order) a vector or factor (partially) into ascending or descending order. For ordering along more than one variable, e.g., for sorting data frames, see order.

order():

order returns a permutation which rearranges its first argument into ascending or descending order, breaking ties by further arguments. sort.list is the same, using only one argument.

pascal
  • 1,036
  • 5
  • 15