I would like to find away to bind.rows cumulatively. Here is small example, what I would like to achieve. I will demo with gapminder dataset from dslabs package.
library(tidyverse)
library(dslabs)
gapminder %>%
group_by(year) %>%
nest() %>%
head(5)
A tibble: 5 x 2
year data
<int> <list>
1 1960 <tibble [185 x 8]>
2 1961 <tibble [185 x 8]>
3 1962 <tibble [185 x 8]>
4 1963 <tibble [185 x 8]>
5 1964 <tibble [185 x 8]>
I would like to create column, which would bind earlier observations from data column together. So for example row 1 only would have year 1960 data, row 2 would have 1960 + 1961 data, row 3 1960 + 1961 + 1963 data... End result should look something like this.
# A tibble: 5 x 3
year data cumulative_data
<int> <list> <list>
1 1960 <tibble [185 x 8]> <tibble [185 x 8]>
2 1961 <tibble [185 x 8]> <tibble [370 x 8]>
3 1962 <tibble [185 x 8]> <tibble [555 x 8]>
4 1963 <tibble [185 x 8]> <tibble [740 x 8]>
5 1964 <tibble [185 x 8]> <tibble [925 x 8]>