I have a dummy dataset with 10 Hospitals, with a record of how many jobs there are for a specific date at that Hospital. The dates are taken weekly, and missing dates mean 0 jobs that week.
set.seed(2020)
df1 <- data.frame(
Date = as.Date(sample( as.numeric(as.Date('2011-01-01')): as.numeric(as.Date('2013-04-14')), 10, replace = T), origin = '1970-01-01'),
Hospital = sample(1:10,replace=T),
Jobs = rpois(10,2))
I would like to fill in the missing dates (taken weekly) for each Hospital, so there are 120 entries for each Hospital (as there are 120 weeks between 2011-01-01 and 2013-04-14), with the 'Jobs' variable assigned to 0 for the new dates. Hence outputting a dataframe with 1200 rows (10 Hospitals each with 120 weeks of entries).
Note: I have tried a solution along these lines: R fill missing dates by category but it only fills in the missing dates between the min and max that are already in the data and not for the dates defined above. I have also tried adding in start and end dates into the data manually for each Hosptial, applying the solution, then removing them again but this does not work as intended.