[R] flatten a list

Therneau, Terry M., Ph.D. therneau at mayo.edu
Tue Sep 29 17:00:30 CEST 2015

I'd like to flatten a list from 2 levels to 1 level.  This has to be easy, but is currently opaque to me.

temp <- list(1:3, list(letters[1:3], duh= 5:8),  zed=15:17)

Desired result would be a 4 element list.
[[1]] 1:3
[[2]] "a", "b", "c"
[[duh]] 5:8
[[zed]] 15:17

(Preservation of the names is not important)

Terry T

More information about the R-help mailing list