Quantcast
Channel: Flatten recursive list - Stack Overflow
Browsing latest articles
Browse All 5 View Live

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 Article



Answer 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 Article

Answer 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 Article

Answer 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 Article

Flatten 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

Browsing latest articles
Browse All 5 View Live




Latest Images