Model Code Repository
Welcome
The Virtual Academy Model Code Repository gives corrections analysts access to a variety of code templates written in the R statistical programming language to improve data analytic efficiency and accuracy. This repository includes code to help reduce time spent compiling reports, tables, and visualizations.
Additionally, all templates encourage reproducibility to prevent data discrepancies and simplify common time-consuming tasks. Analysts can use these templates to do the following:
- Clean and manipulate population and corrections data for reporting.
- Calculate relevant metrics.
- Produce meaningful, digestible data visualizations.
Currently, there are three templates available, and more will be added in the coming months.
Why R?
The following templates are written in R, a programming language used for data analysis, data visualization, and statistics. CSG Justice Center staff favor using R for a number of reasons:
- R is free and open source.
- R encourages automation and reproducibility.
- Data analysis using code allows for quality assurance.
- R has a robust online community.
There are many other languages and tools for data analysis such as Python, SAS, and Stata. If you already are familiar with those languages, you can still find value in these templates, as the processes and workflows are similar.
Model Code Templates
Visualizing State Recidivism Rates
This model code will allow you to produce four data visualizations from the public report 50 States, 1 Goal: Examining State-Level Recidivism Trends in the Second Chance Act Era. Utilizing the provided model code in the R statistical programming language on your local computer, you will be able to replicate the process of importing aggregated recidivism data, conducting simple calculations, merging datasets, and finally creating data visualizations displaying recidivism trends through bar charts and arrow charts. This model code is reproducible and includes quality assurance checks for accuracy.
Supervision Violations Data and Creating Highcharts
This model code will allow you to produce three data visualizations from the public report Supervision Violations and Their Impact on Incarceration. Utilizing the provided model code in the R statistical programming language on your local computer, you will be able to replicate the process of importing data, cleaning and wrangling these data, and finally creating data visualizations displaying supervision and non-supervision violation prison admission trends through area charts, supervision violation prison admission trends by violation type through bar charts, and a hex map of change in total prison admissions. This model code is reproducible and includes quality assurance checks for accuracy.
Prison Population and Length of Stay Trends
This model code will allow you to produce three data visualizations from the state-specific Justice Data Snapshots, published by The CSG Justice Center. Utilizing the provided model code in the R statistical programming language on your local computer, you will be able to replicate the process of importing data, cleaning and wrangling these data, and finally creating data visualizations displaying prison releases and prison population through bar charts. Additionally, you will use R to create dynamic paragraphs of text that can be inserted into reports.
About Virtual Academy
The Advancing Data in Corrections initiative includes a Virtual Academy, which builds data literacy and analytic capabilities within departments of corrections nationwide to further data-informed planning and decision-making. Through their participation in the Virtual Academy, corrections agency staff can access the program’s self-paced learning materials, community forum, peer-to-peer networks, and technical assistance at no cost.
For more information about the program and the tools, services, and opportunities available, visit the Virtual Academy website.