[R] trying to produce an array of ranks

John Christie jc at or.psychology.dal.ca
Thu Aug 28 01:32:27 CEST 2003


OK, I am try to produce an array of ranks.  I have a set of data (s) 
that looks like this

rt	subj
312	dave
467	dave
411	dave
383	kim
398	kim
...

Now I want to make a column that is an array of the ranks of rt by 
subject.  The closest of gotten is using the following.

r <- by (s, s$subj, function(d) rank(d[1]))

This gets the data out with ranks but I cannot figure out how to easily 
extract each of the lists and turn the whole thing into a nice straight 
array (it is an array of lists when unclassed).  I couldn't get 
anything working with any of the apply's or ave.  Any suggestions?  
This seems like it should be a common task.




More information about the R-help mailing list