Answer by G. Grothendieck for Flatten recursive list
rrapply in the rrapply package is a generalization of rapply that can flatten the nested list into a list of leaves. dfaslist=FALSE will cause data frames to be regarded as leaves rather than being...
View ArticleAnswer by alistaire for Flatten recursive list
rlang::squash is pretty magical:set.seed(47)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),])...
View ArticleAnswer by Claus Wilke for Flatten recursive list
This is a general flatten function using only base R:flatten <- function(x) { if (!inherits(x, "list")) return(list(x)) else return(unlist(c(lapply(x, flatten)), recursive =...
View ArticleAnswer by hrbrmstr for Flatten recursive list
Your data: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),] ) ) ) ))First, a crude,...
View ArticleFlatten recursive list
There are quite a few questions apparently on this topic, but I can't see any general solution proposed: I have a deeply recursive list and want to flatten it into a single list of all the non-list...
View Article
More Pages to Explore .....