This document explains how to use json OCDS data in R.

Transforming json data to dataframes

To load json data in R, we can use the fromJSON command from the jsonlite package. For this example we will use sample data from Colombia, that you can download in this link.

Setup

Set your working directory and load the packages:

setwd("SET YOUR WORKING DIRECTORY")
library(jsonlite)
library(dplyr)

Load the data and explore the structure

1- Load the data with the fromJSON command. Use the option flatten=TRUE to flatten the json data into a list.

2- The list only has one element, a dataframe called releases that contains all the data. We extract it from the list with the command data[["releases"]] and transform it into a tibble as_tibble.

3- Explore the structure of the dataframe. The releases dataframe has different list columns, each containing dataframes; these dataframes correspond to arrays in the json data.