Skip to content
Prev 157319 / 398506 Next

Newbie: Ranking a data frame, grouped by 2 or more columns

Hi,

I'd like to rank obs in a data frame as subset by 2 or more columns...
The example input would look like the following:

====+====+====+====+
x   y   v
--  --  --
a   w   200
a   w   100
b   w   500
b   w   200
b   z   300
b   z   400
====+====+====+====+

And the data frame I want to create is below:
====+====+====+====+
x   y   v   rank
--  --  --  ----
a   w   200    1
a   w   100    2
b   w   500    1
b   w   200    2
b   z   300    2
b   z   400    1
====+====+====+====+

Can someone help me with this?

Thanks,
Matt