I am using R and I want to create a column showing a sequence or rank, while grouping by two factors (hhid and period).
For example, I have this data set:
hhid perid
1000 1
1000 1
1000 1
1000 2
1000 2
2000 1
2000 1
2000 1
2000 1
2000 2
2000 2
I want to add a column called "actno" like this:
hhid perid actno
1000 1 1
1000 1 2
1000 1 3
1000 2 1
1000 2 2
2000 1 1
2000 1 2
2000 1 3
2000 1 4
2000 2 1
2000 2 2