jsonrrjsoniojsonlite

rbind.pages with missing pages "Error: all(vapply(pages, is.data.frame, logical(1)))" is not TRUE


I am trying to rbind.pages with jsonlite from web where some of the data files are missing(for example values for aa are missing).

temp<- c("6702","1","67")
library(jsonlite)
baseurl <- "https://api.angel.co/1/startups/"
pages <- list()
for(i in 1:3){
  mydata<- fromJSON(paste0(baseurl,temp[[i]]),flatten= TRUE)
 pages[[i+1]] <- mydata
}
out<- rbind.pages(pages[sapply(pages, length)>2])

I am getting the following errors. Any suggestions on how to address this? Thanks.

Error: Error in open.connection(con, "rb") : HTTP error 404.
Error: all(vapply(pages, is.data.frame, logical(1))) is not TRUE

Solution

  • rbind.pages doesn't appear to like "empty" lists. You should filter your list to exclude them

    out<- rbind.pages(pages[sapply(pages, length)>0])