I have 200 numbers all between 0 and 1. I would like to rank them and assign integer values 1-199. It could be something very easy to accomplish but i don't know which function to use - the order function does not really work.
say here is what I have:
0.12, 0.56, 0.112, 0.8, 0.356, 0.00001
I want:
3, 5, 2, 6, 4, 1
Thank you!!
There is a built in function for exactly this purpose:
x <- runif(10)
rank(x)
[1] 7 3 8 10 4 2 5 1 6 9
see ?rank
for the options for dealing with ties.
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