Suppose I have this dataset:
Year ID Value
1 1999 1 1.3
2 2000 1 1.4
3 2001 1 1.5
4 2002 1 1.3
5 2003 1 5.0
6 2000 2 3.4
7 2003 2 1.2
I want Year
variable to range from 1999 to 2003 for every ID/observation. Of course in extending the dataset, I am also creating NAs values for the variable Value
. In other words, this is what I want:
Year ID Value
1 1999 1 1.3
2 2000 1 1.4
3 2001 1 1.5
4 2002 1 1.3
5 2003 1 5.0
6 1999 2 NA
7 2000 2 3.4
8 2001 2 NA
9 2002 2 NA
10 2003 2 1.2
How do I do this on R?