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?
Try using order
> order(x, decreasing =TRUE)
[1] 6 5 2 1 3 4
Try this:
> order(-x)
[1] 6 5 2 1 3 4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With