This is a simple one but it is stumping me. I have a data frame consisting of day-level observations by individuals. However, not all individuals are observed on the same day. I need to create rows including the days in which individuals are not observed (i.e., count NaN or 0), between the dates where they are present.
The relevant data looks as follows
ID date StartDate EndDate Count Cov1 Cov2 Cov3
A 05/05/2005 04/04/05 06/06/2006 3 1 F 1
A 06/05/2005 04/04/05 06/06/2006 5 1 F 1
A 07/05/2005 04/04/05 06/06/2006 2 1 F 1
A 10/05/2005 04/04/05 06/06/2006 7 1 F 1
B 05/05/2005 04/04/05 06/06/2006 6 0 M 2
B 07/05/2005 04/04/05 06/06/2006 1 0 M 2
C 01/05/2005 04/04/05 06/06/2006 3 1 F 1
C 03/05/2005 04/04/05 06/06/2006 7 1 F 1
However, I need it to look like this:
ID date StartDate EndDate Count Cov1 Cov2 Cov3
A 05/05/2005 04/04/05 06/06/2006 3 1 F 1
A 06/05/2005 04/04/05 06/06/2006 5 1 F 1
A 07/05/2005 04/04/05 06/06/2006 2 1 F 1
A 08/05/2005 04/04/05 06/06/2006 0 1 F 1
A 09/05/2005 04/04/05 06/06/2006 0 1 F 1
A 10/05/2005 04/04/05 06/06/2006 7 1 F 1
B 05/05/2005 04/04/05 06/06/2006 6 0 M 2
B 06/05/2005 04/04/05 06/06/2006 0 0 M 2
B 07/05/2005 04/04/05 06/06/2006 1 0 M 2
C 01/05/2005 04/04/05 06/06/2006 3 1 F 1
C 02/05/2005 04/04/05 06/06/2006 0 1 F 1
C 03/05/2005 04/04/05 06/06/2006 7 1 F 1
So, the data should expand by days not counted in the original but between the start and end dates. However, the count variable must not copy over, while all other covariates have to copy.