I'm using rbind as part of a function to write json data to a simple data frame in R. I've nearly successfully created my df, but rather than writing in NULL values as "NA" my r script prints the next available variable in the frame that should be null. In other words, I'm seeing data laid into rows improperly (ex. The row 3 values of "access_method.created_at" and "access_method.method" are null, and therefore the row is offset by two variables (the "access_method.created_at" and "access_method.method" are showing "address" and "capacity", and so on). Is there a way to account for these null values?
library(httr)
library(jsonlite)
perpage <- "per_page="
pagenumber <- "page="
pp <- 5000
pn <- 0
vpg <- GET("https://api.seatgeek.com/2/venues?country=US&per_page=5000&page=1&client_id=NTM2MzE3fDE1NzM4NTExMTAuNzU&client_secret=77264dfa5a0bc99095279fa7b01c223ff994437433c214c8b9a08e6de10fddd6")
vpgc <- content(vpg)
vpgcv <- (vpgc$venues)
json_file <-
as.data.frame(
Reduce(function(x, y) {
rbind(unlist(x), unlist(y))
}, vpgcv)
)
venues.dataframe <- as.data.frame(t(json_file))
I've attempted to leverage rbindlist
which has a null value function fill = TRUE
to no luck. I'd appreciate any suggestions to recognize these NULL values and properly generate a flat dataframe. Thanks!