I've got some data in the following shape:
UPDATE: My data has an extra variable I'd like to group by. I used ddply with the below solution provided by Richie but did not work.
Country,group, date
US,A,'2011-10-01'
US,B,'2011-10-01'
US,C,'2011-10-01'
MX,D,'2011-10-01'
UK,E,'2011-10-02'
UK,B,'2011-10-02'
UK,A,'2011-10-02'
UK,C,'2011-10-02'
The data frame is already ordered so A came first, B second and so on so forth. What I am trying to create is a rank variable by date like this:
Country,group, date,rank
US,A,'2011-10-01',1
US,B,'2011-10-01',2
US,C,'2011-10-01',3
MX,D,'2011-10-01',1
UK,E,'2011-10-02',1
UK,B,'2011-10-02',2
UK,A,'2011-10-02',3
UK,C,'2011-10-02',4
....