Skip to content

Auto casting in rbind_all #493

@jeroen

Description

@jeroen

The following works in plyr, it would be great to get it to work in dplyr as well.

mydata <- list(
  data.frame(x=c("foo", "bar")),
  data.frame(x=NA)
)

plyr::rbind.fill(mydata)
dplyr::rbind_all(mydata)

Some context: such data often appear when parsing json, in which a null might become NA. For example:

#requires jsonlite >= 0.9.9
library(jsonlite)

#store all pages in a list first
baseurl <- "http://projects.propublica.org/nonprofits/api/v1/search.json?order=revenue&sort_order=desc"
pages <- list()
for(i in 0:20){
  mydata <- fromJSON(paste0(baseurl, "&page=", i), flatten=TRUE)
  message("Retrieving page ", i)
  pages[[i+1]] <- mydata$filings
}

#combine all into one 
library(plyr)
filings <- rbind.fill(pages)

Metadata

Metadata

Labels

featurea feature request or enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions