[R] Ranking within a classification variable.
    Rolf Turner 
    rolf at math.unb.ca
       
    Tue Apr 19 17:47:39 CEST 2005
    
    
  
Suppose I have a data frame with two columns ``district'' and
``score'' --- score is numeric; district may be considered
categorical.
I wish to append to this data frame a third column whose entries are
the ranks of ``score'' ***within*** district.
I've tried fiddling about with tapply() and by() but the result is a
list whose i-th component consists of the ranks of the scores within
the i-th district.  I then have trouble figuring out how to put these
results into a column of the data frame in the proper order.
Is there a slick-quick-sexy way of doing this (without resorting to
looping)?  Am I missing something obvious?
Thanks for any help bestowed.
				cheers,
					Rolf Turner
					rolf at math.unb.ca
    
    
More information about the R-help
mailing list