Split the list of data.frames into sublists data.frames
I have a list of data.frames that looks like this:
List
[[1]]
.....
List
[[2]]
....
List
[[95]]
I would like to split this long list of data.frames into sublists of 3 data.frames each to do other calculations in a simple and easy way.
Something like:
sublist1 <- List [1: 3]
sublist2 <- List [3: 6]
sublist3 <- List [6: 9]
etc.
+3
source to share
2 answers
I would do something like this:
ll <- by(seq_along(l),cut(seq_along(l),3),
FUN=function(x)l[x])
Now I have a list containing 3 lists. For example, to access the first sub-lists, you can:
ll[[1]]
[[1]]
data frame with 0 columns and 0 rows
[[2]]
data frame with 0 columns and 0 rows
[[3]]
data frame with 0 columns and 0 rows
And so on, ll [[2]] ...
+3
source to share