Working with API and JSON format

API
Data analysis
The task was to find the average sentence length of OWI (operating while intoxicated) offenders on their 3rd or more OWI citation.
Author
Affiliation

Jacci Ziebert

WisDOT

Published

October 4, 2022

What I learned

This was done it two parts 1) Writing functions that pulls data from our court case API into a JSON format over a certain time period and for certain citations. This data was flattened and compiled into a single dataframe and exported. And 2) Finding the sentence length for a certain citation for each case. This was tricky as one case may have multiple citations while sentence lengths can be found in multiple branches of the flattened JSON. I solved this issue by finding which branch a certain location was found and replaced part of the branch name with where the sentence length location. I was able to extract the sentence length with this ‘renaming.’ to calculate the average sentence length.

Highlighted packages

jsonlite, httr