I have the following dataset:
ID year start_year
a 1 1
a 2 1
a 3 1
b 1 2
b 2 2
b 3 2
c 1 3
c 2 3
c 3 3
And I want to create a new dummy column present that, for each ID is, 1-1-1 if start_year is 1, is 0-1-1 if start_year is 2, and is 0-0-1 if start_year is 3.
My goal is to get the following table:
ID year start_year present
a 1 1 1
a 2 1 1
a 3 1 1
b 1 2 0
b 2 2 1
b 3 2 1
c 1 3 0
c 2 3 0
c 3 3 1
I guess this should be fairly easy for most of you, but I'm really stuck. Many thanks for your help!