R list(structure(list())) to data frame R list(structure(list())) to data frame json json

R list(structure(list())) to data frame


If you have a jagged list you want converted to a data.frame, you could use Hadley's plyr's rbind.fill. Saved my neck on a couple of occasions. Let me know if this is what you're looking for. Notice that I modified your first example to include only "b" in the third element to make it jagged.

> x <- list(+         structure(list(a = "foo", b = "sdfshk"), .Names = c("a", "b")),+         structure(list(a = "foo", b = "ihlkyhul"), .Names = c("a", "b")),+         structure(list(b = "asdf"), .Names = "b")+ )> > library(plyr)> do.call("rbind.fill", lapply(x, as.data.frame))     a        b1  foo   sdfshk2  foo ihlkyhul3 <NA>     asdf