Hello,
What is the best way to get ranks for a vector of values, limit the range
of rank values and create equal count in each group? I call this uniform
ranking...uniform count/number in each group.
Here is an example using three groups:
Say I have values:
x = c(3, 2, -3, 1, 0, 5, 10, 30, -1, 4)
names(x) = letters[1:10]
> x
a b c d e f g h i j
3 2 -3 1 0 5 10 30 -1 4
I would like:
a b c d e f g h i j
2 2 1 2 1 3 3 3 1 3
Same thing as above, maybe easier to see:
c i e d b a j f g h
-3 -1 0 1 2 3 4 5 10 30
I would get:
c i e d b a j f g h
1 1 1 2 2 2 3 3 3 3
Note that there are 4 values with a rank of 3 because I can't get even
numbers (10/3 = 3.333).
Been to ?sort, ?order, ?quantile, ?cut, and ?split.
Thanks,
Ben
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.