I have a dataset about start and end dates, and I want to expand them to consecutive dates in rows. The dataset looks like this (df1):
id deg from to
1 1 2010-03-01 2010-03-05
1 1 2010-03-20 2010-03-25
1 2 2010-06-01 2010-06-05
And this is the result I want (df2):
id deg date
1 1 2010-03-01
1 1 2010-03-02
1 1 2010-03-03
1 1 2010-03-04
1 1 2010-03-05
1 1 2010-03-20
1 1 2010-03-21
1 1 2010-03-22
1 1 2010-03-23
1 1 2010-03-24
1 1 2010-03-25
1 2 2010-06-01
1 2 2010-06-02
1 2 2010-06-03
1 2 2010-06-04
1 2 2010-06-05
Here's the different codes I've tried:
df2 = df1 %>%
mutate(id= 1:nrow(.)) %>%
rowwise() %>%
do(data.frame(id=.$id, date=seq.Date(.$from, .$to, by="days")))
But it keeps showing the error: wrong sign in 'by' argument
Thank you all in advance!