Skip to content
Prev 5887 / 398506 Next

computing ranks in subgroups

Dear R-users!

I am using R 1.0.0 and Windows NT 4.0. I want to compute ranks for the
values of a variable, in several subgroups of a data.frame.
Currently I use:
val=c(10,3,9,3,5,1,7))
group val
1     A  10
2     A   3
3     B   9
4     A   3
5     B   5
6     B   1
7     A   7
group val valgroupranks
1     A  10           4.0
2     A   3           1.5
4     A   3           1.5
7     A   7           3.0
3     B   9           3.0
5     B   5           2.0
6     B   1           1.0
This seems to work, but I wonder if there is a more "natural" (simple?) way
to do that?

Heinrich..
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._