I have a dataset like this:
id date value
1 8/06/12 1
1 8/08/12 1
2 8/07/12 2
2 8/08/12 1
Every id should a have a value for every date. When an id is missing a particular date, that row needs to be added with a value of 0. E.g.,
id date value
1 8/06/12 1
1 8/07/12 0
1 8/08/12 1
2 8/06/12 0
2 8/07/12 2
2 8/08/12 1
I'm trying to figure out how to add the rows with 0s. There's a good solution here: R - Fill missing dates by group. However, I can't use the tidyr::complete
function because I'm using sparklyr
and, as far as I know, need to stay within dplyr
functions.