Skip to content

Instantly share code, notes, and snippets.

@swayson
Last active November 4, 2015 09:33
Show Gist options
  • Save swayson/62005952d7ed2b834a0c to your computer and use it in GitHub Desktop.
Save swayson/62005952d7ed2b834a0c to your computer and use it in GitHub Desktop.
Convert a list of items into a flat dataframe.
mylist <- list(structure(list(Hit = "True", Project = "Blue", Year = "2011",
Rating = "4", Launch = "26 Jan 2012", ID = "19", Dept = "1, 2, 4"), .Names = c("Hit",
"Project", "Year", "Rating", "Launch", "ID", "Dept")), structure(list(
Hit = "False", Error = "Record not found"), .Names = c("Hit",
"Error")), structure(list(Hit = "True", Project = "Green", Year = "2004",
Rating = "8", Launch = "29 Feb 2004", ID = "183", Dept = "6, 8"), .Names = c("Hit",
"Project", "Year", "Rating", "Launch", "ID", "Dept")))
dfs <- lapply(mylist, data.frame, stringsAsFactors = FALSE)
library(dplyr)
rbind_all(dfs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment