I have data which looks like this:
person_id y_var x_var
1 98 51
1 96 90
1 57 13
2 80 38
2 14 5
3 21 28
3 18 25
3 47 41
3 72 57
Can anyone tell me how to number each person's observations sequentially in the following way? In this simplified data set the person_id
is a number but in my data it is an alphanumeric factor.
person_id instance_id y_var x_var
1 1 98 51
1 2 96 90
1 3 57 13
2 1 80 38
2 2 14 5
3 1 21 28
3 2 18 25
3 3 47 41
3 4 72 57
Thanks.