Reputation: 1119
I have a vector:
x<-rnorm(100)
,
I would like to create a vector that stores the position of the first, second, third...100th highest value in X.
For example if x=4,9,2,0,10,11
then the desired vector would be 6,5,2,1,3,4
is there a function for doing this?
Upvotes: 5
Views: 2534
Reputation: 61154
Try using order
> order(x, decreasing =TRUE)
[1] 6 5 2 1 3 4
Upvotes: 8