I want to get the a vector including the order index of each value in myvec.
myec has 13 elements. so my result vector must begin with 13, showing 2821774 is largest value in myvec. but when I use ORDER function the output is not correct obviously.
myvec <- c(2821774, 435266, 101643, 38311, 280264, 716010, 546901, 16732 , 87282,
329322, 156031, 1018510, 77215)
order(myvec)
[1] 8 4 13 9 3 11 5 10 2 7 6 12 1
how am I supposed to get the result vector correctly?
CodePudding user response:
We may need rank
rank(myvec)
[1] 13 9 5 2 7 11 10 1 4 8 6 12 3
Or do a double order
order(order(myvec))
[1] 13 9 5 2 7 11 10 1 4 8 6 12 3