In tabel df1 I have housenumbers from-to and the required fill up sequence:
ID HsnrFrom HsnrTo sequence
180700241 64 68 2
180901612 179 183 2
180900571 8 11 1
180900680 9 13 2
I want to multiply the rows, tot get a dataframe with all housenumbers in the range from-to in df2. Because of the even and odd numbering the filling has to be based ond the displayed sequence:
ID HsnrFrom HsnrTo sequence Hsnr
180700241 64 68 2 64
180700241 64 68 2 66
180700241 64 68 2 68
180901612 179 183 2 179
180901612 179 183 2 181
180901612 179 183 2 183
180900571 8 11 1 8
180900571 8 11 1 9
180900571 8 11 1 10
180900571 8 11 1 11
180900680 9 13 2 9
180900680 9 13 2 11
180900680 9 13 2 13
I have tried to translate this script to my challenge. For each row in a data frame, create multiple rows based on date ranges
library(data.table)
setDT(df)[, c('StartDate', 'EndDate') := lapply(.SD, as.Date, format = '%m/%d/%Y'), .SDcols = 2:3
][, .(date = seq(StartDate, EndDate, 'day')), by = .(Name, StartDate, EndDate)]
Unfortunately, I can't figure it out. That is why I hope for good advice.