Skip to content

Instantly share code, notes, and snippets.

@mrdwab
Created February 18, 2016 11:38
Show Gist options
  • Save mrdwab/fa4db143220b99dfdd99 to your computer and use it in GitHub Desktop.
Save mrdwab/fa4db143220b99dfdd99 to your computer and use it in GitHub Desktop.
meltList <- function(inlist) {
require(data.table)
f <- function(l) {
names(l) <- seq_along(l)
lapply(l, function(x) {
x <- setNames(x, seq_along(x))
if(is.list(x)) f(x) else x
})
}
temp <- unlist(f(inlist))
setDT(tstrsplit(names(temp), ".", fixed = TRUE))[
, value := unname(temp)][]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment