Making US Crime Data Accessible with R Shiny

Posted on Feb 20, 2023

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.

From Perceptions of Increased U.S. Crime at Highest Since 1993, by Justin McCarthy, 2020 ( Copyright 2023 by Gallup, Inc.


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.

Final Thoughts

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.

About Author

Grainne O'Neill

As a soon-to-be Ph.D. graduate with a background in mathematics and a passion for data science, I am seeking opportunities to leverage my skills and enthusiasm for solving complex problems through data-driven insights.
View all posts by Grainne O'Neill >

Related Articles

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI