I'm having trouble parsing a json file into a dataframe in R. I've been able to turn the json file into a data frame, but I can't seem to unnest the "geometry" column. Below is a sample of the json file
[
{
"point_id": 4,
"geometry": {
"type": "Point",
"coordinates": [
-101.5961904,
31.7070736
]
},
"NumericID": "4543842",
}
]
When I try to unnest using the code below, I get an error.
ex_data<-lapply(ex_data, function(x) ifelse (x == "NULL", NA, x))
ex_data<-as.data.frame(do.call(rbind, ex_data))
ex_data<-ex_data%>% bind_rows(ex_data) %>% # make larger sample data
mutate_if(is.list, simplify_all) # flatten each list element internally
ex_data%>%unnest(geometry)->ex_data_unnest
Error: Each column must either be a list of vectors or a list of data frames
[geometry]
Thanks