Assume I have the data
item cond foo
1 1 3.733333
2 1 4.766667
3 1 4.133333
4 2 4.466667
5 2 2.800000
6 2 2.300000
I need to generate a new column that uniquely identifies an item
per cond
value, so I'd like to get:
item cond foo item_per_cond
1 1 3.733333 1
2 1 4.766667 2
3 1 4.133333 3
4 2 4.466667 1
5 2 2.800000 2
6 2 2.300000 3
I figured I'd go with something like this, but I have no idea what the ...
should be here?
ddply(d, .(cond), transform, ...)