Assign integer order to decimal numbers

I have 200 numbers between 0 and 1. I would like to rank them and assign integer values ​​1-199. It can be very easy to do, but I don’t know which function to use - the order function really does not work.

let's say this is what I have:

    0.12, 0.56, 0.112, 0.8, 0.356, 0.00001

I want to:

    3, 5, 2, 6, 4, 1

Thank!

+5
source share
1 answer

For this purpose, there is a built-in function:

x <- runif(10)
rank(x)
[1]  7  3  8 10  4  2  5  1  6  9

see ?rankfor options for interacting with communication.

+9
source

All Articles