DEV Community

Cover image for Pulling JSON Data using R
Swapan
Swapan

Posted on

Pulling JSON Data using R

Simple code to pull JSON data and convert into .xlsx format.

Code created using R Studio version R-3.6.1

Alt Text

   # Import packages 
  install.packages("rjson")
  install.packages("jsonlite")
  library("rjson")
  library("jsonlite")
  install.packages("openxlsx")
  library(openxlsx)

  # Place from where we need to download JSON file (sample URL)

   json_file <-"https://opendata.ecdc.europa.eu/covid19/casedistribution/json/"


  # read url and convert to data.frame
  document <- fromJSON(txt=json_file)
  summary(document)
  # Location where the .xls file will be saved
  write.xlsx(document, "/COVID19.xlsx")
Enter fullscreen mode Exit fullscreen mode

The data that will be pulled in can be used to create visulization.
Below is sample tableau visualization.

https://public.tableau.com/profile/swapanroy#!/vizhome/Covid19spread/COVID19-Curve

Top comments (0)