I am working with nested lists in R. Basically, I have the lists running through a function to compose all of the sub-lists and I need to collapse them. Suppose I have a list like this
[[1]]
[[1]][[1]]
[1] 2
[[2]]
[[2]][[1]]
[1] 1
[[3]]
[[3]][[1]]
[1] 4
[[3]][[2]]
[1] 22
[[3]][[3]]
[1] 2 2
[[4]]
[[4]][[1]]
[1] 3
[[4]][[2]]
[1] 12
[[4]][[3]]
[1] 1 2
How would I collapse this to one list like so
[[1]]
[1] 2
[[2]]
[1] 1
[[3]]
[1] 4
[[4]]
[1] 22
[[5]]
[1] 2 2
[[6]]
[1] 3
[[7]]
[1] 12
[[8]]
[1] 1 2
I'm sure that it involves some form of lapply and unlist but I can't seem to get it to work...