I am trying to transform a dataframe df consisting of a value-column, two date columns (start and end), and a interval-column (duration) into the long format by unnesting/unstacking the duration column.
library(dplyr)
library(lubridate)
df <- data.frame(value = letters[1:3], start = as_date(1:3), end = as_date(3:1)+3) %>%
mutate(duration = interval(start, end))
The expected outcome would a dataframe where value, start, and end are duplicated for each day as defined by duration. For instance, the value 'a' would appear 6 times each time on a different day (2nd, 3rd, 4th, 5th, 6th, 7th January 1970).
I tried to use the unnest function from the tidyr package but nothing happened.
tidyr::unnest(df, duration)
Any help is greatly appreciated :)