Making US Crime Data Accessible with R Shiny
Crime is rising. No, it’s falling. The topic of crime in the US raises clashing views and opinions. Americans primarily rely on the news and media to understand the state of crime in the country, and it can be difficult to get the full picture. According to Gallup, Americans are more likely to believe national crime is up than they are to believe crime in their local area is up. As demonstrated by the figure below, in 2020, 78% of Americans believed national crime was up since the previous year, and only 38% believed crime was up in their local area since the previous year. Not only is this gap large, it is also overly pessimistic. In reality, crime rates have been falling.
To help bridge the gap between our perceptions and the data, I designed an R Shiny app that allows users to explore FBI violent crime data in different states and years. The intention is to make crime data more accessible and allow Americans to develop more informed opinions about crime. The interactive nature of the app makes it possible to render thousands of different visualizations that the user can choose to explore.
→ Click here to open the app and explore it for yourself! ←
The app uses FBI violent crime data from the years 1975-2015, downloaded from this Kaggle dataset. The data includes the four types of violent crimes as defined by the FBI— homicide, rape, robbery and assault— from 68 police jurisdictions that have populations greater than 250,000. The data is in the form of annual crime rates per capita, defined as crime per 100,000 people in the state's population. Since reporting data to the FBI is optional, some states contain no data.
Using the app
Time Series of Crime by State
The first interactive tool in the app is the time series visualization. The user can select a time frame, a specific crime or all crimes, and a state. Shown below is a screenshot where the user chose to look at all violent crimes over the full time series in New York. There were four police jurisdictions in the data set for New York: Buffalo, Nassau County, New York City, and Suffolk County. This plot shows that Buffalo and New York City have higher crime than the other counties and that crime has been trending down with a large drop in the '90s.
Heat Map of US Crime by Year
The next interactive tool in the app is the heat map of crime in each state. The user can select a specific year and a specific crime or all crimes. Let's say the user was curious about the large crime rates in the '90s. Below is an example where the user chose to look at assaults in 1994. The map has a lot of orange and red, indicating high assault rates. How does this compare to more recent years?
Heat Map of Changes in US Crime
The third interactive tool on the app allows the user to compare crime rates between two different years. Below, the user selected 1994 and 2015 assaults to determine if the assault rates in 1994 were high compared to more recent years. The states in green experienced a decrease in assaults over this time frame (upwards of -300% in some states) suggesting assaults decreased over much of the country since 1994.
With these three interactive visualizations, users can explore the data in a way that is easy to implement and digest. The app can even help people make more informed decisions about the safety of a neighborhood they’d consider when moving to a new state or choosing between Buffalo and Suffolk County, New York, for example. Making crime data more accessible allows Americans to form their opinions based on accurate information rather than inaccurate impressions from media reports and representation.
Visit the github for this project to explore the code.