Hi,
This is one more question related to importing data from JSON API.
library(httr)
library(dplyr)
jsonResponse <-GET("https://api.covid19india.org/districts_daily.json")
jsonResponseParsed dist<- content(jsonResponse, as="parsed")
jsonResponseParseddist
modJsondist<-jsonResponseParseddist$districtsDaily
modJsondist
This gives me a heirarchical data. From here my intention is to convert it in a readable format and export to csv file for further analysis. I use the below code:-
rawddist <- modJsondist%>% bind_rows %>% select("Andhra pradesh", "Bihar", "Delhi", "Gujarat", "Haryana", "Jammu and Kashmir", "Jharkhand", "Karnataka", "Kerala", "Ladakh", "Madhya Pradesh", "Maharashtra", "Odisha", "Punjab", "Rajasthan", "Tamil Nadu", "Telangana", "Uttar Pradesh", "West Bengal")
However it throws an error as shown below:-
Error: Argument 3 must be length 14, not 4
I am not sure what is going wrong.
I need two help here:-
- Some explannation on how to read the hierarchical data the JSON API returns
- Any help in terms of what is wrong with the code and how to fix it.