There are quite a few questions on this topic, but I don’t see any general solution: I have a very recursive list and you want to smooth it into one list of all the elements contained outside the lists.
For example, take this nested list:
d = list( list( list( iris[sample(1:150,3),], iris[sample(1:150,3),] ), list( list( iris[sample(1:150,3),], list( iris[sample(1:150,3),], iris[sample(1:150,3),] ) ) ) ) )
And include it in this:
list(iris[sample(1:150,3),], iris[sample(1:150,3),], iris[sample(1:150,3),], iris[sample(1:150,3),], iris[sample(1:150,3),])
I have tried some of the following based on other solutions:
purrr::flatten(d) plyr::llply(d, unlist) lapply(d, unlist, use.names=FALSE)
There is no achievement of the desired result, which in the example is a single list length of 5, and all elements are data.frame . Any suggestions appreciated.