I want to automatically create multiple Dataframes based on an interval of Dates of another Dataframe. Let's say I have this example:
df <- data.frame(Date = as.Date(c("2022-01-01", "2022-01-01",
"2022-01-02", "2022-01-02", "2022-01-02",
"2022-01-03",
"2022-01-04", "2022-01-04",
"2022-01-05", "2022-01-05", "2022-01-05")),
Name = c(LETTERS[1:11]),
Value = c(1:11))
My goal is to create 3 new Dataframes. df1
should contain the data from 2022-01-01
to 2022-01-04
, df2
should contain the data from 2022-01-02
to 2022-01-05
, and df3
should contain the data from 2022-01-03
to 2022-01-06
. With that, this is the desired Output, with all the objects being as dataframes:
df1 <- data.frame(Date = as.Date(c("2022-01-01", "2022-01-01",
"2022-01-02", "2022-01-02", "2022-01-02",
"2022-01-03")),
Name = c(LETTERS[1:6]),
Value = c(1:6))
df2 <- data.frame(Date = as.Date(c("2022-01-02", "2022-01-02", "2022-01-02",
"2022-01-03",
"2022-01-04", "2022-01-04")),
Name = c(LETTERS[3:8]),
Value = c(3:8))
df3 <- data.frame(Date = as.Date(c("2022-01-03",
"2022-01-04", "2022-01-04",
"2022-01-05", "2022-01-05", "2022-01-05")),
Name = c(LETTERS[6:11]),
Value = c(6:11))
Notice that the number of observations from each date is different. My actual Dataframe is much bigger than the example and it will keep increasing each day, so I need to make this process automatic. Any sugestions?