Hi all,
I have a following data frame
duration = c(2,2,3,3,3)
> start = c("2022-01-01","2022-01-01","2022-02-02","2022-02-02","2022-02-02")
> finish = c("2022-01-02","2022-01-02","2022-02-02","2022-02-03","2022-02-04")
> df <- cbind(start,finish,duration) %>% data.frame()
Currently, each row comes from a copied one and has the same date as the predecessor in a group (in my original dataframe there are also columns allowing for grouping, like name). I would like to change the start column date value based on the duration so that the first row of a new row is always the same, and the following rows have increased value n+1 based on the duration and their distance from the parent row, so the outcome would be the following:
start = c("2022-01-01","2022-01-02","2022-02-02","2022-02-03","2022-02-04")
> finish = c("2022-01-02","2022-01-02","2022-02-02","2022-02-03","2022-02-04")
> df <- cbind(start,finish,duration) %>% data.frame()
I have tried with for loop and if_else but nothing seems to work for me. Thank you for any hints!