I've got a time series of half-hourly observations for about 100 days like so:
> df
# A tibble: 4,704 x 3
city datetime orders
<chr> <time> <dbl>
1 Wien 2016-05-12 00:00:00 1
2 Wien 2016-05-12 00:30:00 4
3 Wien 2016-05-12 01:00:00 2
4 Wien 2016-05-12 01:30:00 0
5 Wien 2016-05-12 02:00:00 5
6 Wien 2016-05-12 02:30:00 10
7 Wien 2016-05-12 03:00:00 11
8 Wien 2016-05-12 03:30:00 22
9 Wien 2016-05-12 04:00:00 4
10 Wien 2016-05-12 04:30:00 2
# ... with 4,694 more rows
I would like to do rolling forecasts on this time series – estimate a model on the first n days worth of data, then predict the n+1st. This is easy using for-loops but I thought I'd give doing this the tidy way a try. So I would like to create a data_frame
that has an end-date as the first column and a data_frame that contains all the data from df up until the end-date in the second that I can then iterate over using purrr::map()
and friends. How do I create this nested data_frame?