I currently have a problem, where I have a data table with start and end date together with an ID. A new table should have the same ID with one column date, containing a sequence of days between first and last day, one day for each row, i.e.
old.table
ID first.date last.date
1 2001-01-01 2001-01-03
2 2002-02-01 2002-02-04
new table
ID date
1 2001-01-01
1 2001-01-02
1 2001-01-03
2 2002-02-01
2 2002-02-02
2 2002-02-03
2 2002-02-04
I know, that calling
seq(first.date,last.date,"day")
creates such a sequence. However, calling
old.table[,date := seq(first.date,last.date,"day")])
throws the exception
Error in seq.Date(first.date, last.date, "day") :
'from' must be of length 1
meaning, that vectorizing the input is not possible (at least not like this).
Is there a way, to get the desired solution?