У меня есть список, который содержит месяцы в комплексе. И я хочу собрать те же месяцы в списке. Элементы января в списке, элементы февраля в списке et c ...
Вот мои данные;
$`01-2011`
date V1
1 01-01-2011 1.48
2 01-02-2011 2.53
$`01-2012`
date V1
366 01-01-2012 0.14
367 01-02-2012 1.18
$`02-2015`
date V1
1493 02-01-2015 10.06
1494 02-02-2015 0.51
$`02-2016`
date V1
1858 02-01-2016 0.00
1859 02-02-2016 2.28
И структура данных;
mix<-list(`01-2011` = structure(list(date = c("01-01-2011", "01-02-2011"
), V1 = c(1.48, 2.53)), row.names = 1:2, class = "data.frame"),
`01-2012` = structure(list(date = c("01-01-2012", "01-02-2012"
), V1 = c(0.14, 1.18)), row.names = 366:367, class = "data.frame"),
`02-2015` = structure(list(date = c("02-01-2015", "02-02-2015"
), V1 = c(10.06, 0.51)), row.names = 1493:1494, class = "data.frame"),
`02-2016` = structure(list(date = c("02-01-2016", "02-02-2016"
), V1 = c(0, 2.28)), row.names = 1858:1859, class = "data.frame"))
Желаемый выход;
$jan
$jan$`01-2011`
date V1
1 01-01-2011 1.48
2 01-02-2011 2.53
$jan$`01-2012`
date V1
366 01-01-2012 0.14
367 01-02-2012 1.18
$feb
$feb$`02-2015`
date V1
1493 02-01-2015 10.06
1494 02-02-2015 0.51
$feb$`02-2016`
date V1
1858 02-01-2016 0.00
1859 02-02-2016 2.28
Желаемая структура вывода;
out<-list(jan = list(`01-2011` = structure(list(date = c("01-01-2011",
"01-02-2011"), V1 = c(1.48, 2.53)), row.names = 1:2, class = "data.frame"),
`01-2012` = structure(list(date = c("01-01-2012", "01-02-2012"
), V1 = c(0.14, 1.18)), row.names = 366:367, class = "data.frame")),
feb = list(`02-2015` = structure(list(date = c("02-01-2015",
"02-02-2015"), V1 = c(10.06, 0.51)), row.names = 1493:1494, class = "data.frame"),
`02-2016` = structure(list(date = c("02-01-2016", "02-02-2016"
), V1 = c(0, 2.28)), row.names = 1858:1859, class = "data.frame")))