indexing according to frequency
- by Bfu38
sorry to bother you. I have a data.frame like this:
24.8
23.2
22.8
22.5
22.5
22.4
22.4
22.4
22.3
22.2
22.2
22.2
22
21.9
21.9
21.8
I would like to add an index according to the frequency, to have the following output:
24.8 1
23.2 1
22.8 1
22.5 2
22.5 2
22.4 3
22.4 3
22.4 3
22.3 1
22.2 3
22.2 3
22.2 3
22 1
21.9 2
21.9 2
21.8 1
How this can be done?
in other words, since 28.8 occurs 1 time, it will have the index 1; since 22.5 occurs two times, it will have index 2 and so on.