I have a data frame that looks like this:
df <- data.frame(project = c("A", "B"),
no_dwellings = c(150, 180),
first_occupancy = c(2020, 2019))
project no_dwellings first_occupancy
1 A 150 2020
2 B 180 2019
project is a column identifying residential building areas, no_dwellings denotes how many dwellings are ultimately being constructed in these areas, and first_occupancy is an estimate as to when the first residents will start moving into the newly constructed apartments.
I need to incorporate this information into a population forecast. The best estimate we have is that in each year (starting with first occupancy), 60 of the dwellings are being moved into. Thus, I need to sequentially generate columns that combine the information from first_occupancy and no_dwellings to indicate for each year how many dwellings are likely to be moved into. Since the number of constructed dwellings does not necessarily divide by 60, the remainder needs to be put into the last column for the respective project.
This is what I expect my data frame to look like for further processing:
project no_dwellings first_occupancy year_2019 year_2020 year_2021 year_2022
1 A 150 2020 0 60 60 30
2 B 180 2019 60 60 60 0