Crime Analysis – Denver-Part 1

Project Background

As we all know, Colorado is considered one of the scariest places on earth. Denver, CO has had an enormous influx of people over the last decade and it is still ramping up.

So why did I pick Denver?

That’s simple, I have lived in Colorado for the majority of my life and want to know more about my capital city.

Exploration of Data
Data provided by

What we’ll do in this post

  • Import the crime.csv data set
  • Format the data
  • Plot the total number of incidents reported by year

Let’s dive in!

Import the necessary libraries

Load the crime data set provided
It is possible to load the data straight from the URL, however, it’s over 80MB in size, so I simply downloaded it. It is updated regularly, so this post may need to be refreshed from time to time.

Format the data
I added columns for year, month, day and hour into the dataframe in order to simplify life. It takes a bit more time and ram upfront but I prefer to see it that way.

Basic Plotting
ggplot2 will provide a decent chart to show us the number of incidents each year.


Adding Some Color
Looking at the same plot but adding in colors for each month of the year.


How much is labeled as TRAFFIC or CRIME
Looking at the same plot but separating out ISTRAFFIC from ISCRIME

Stack bars in colors to view individual months


Initial Impressions
Having isolated only months that have occurred in each year, we’ve seen volume increase most years. The most rapid growth seemed to occur between 2012 – 2014. It appears as if traffic violations seem to be roughly flat and the growth in crimes is much higher. I’ll have to dig into those years in order to see if there’s evidence of a change in crime rate or if something else is hiding in the data.

What I’ll do in the next crime posts

  • Determine year-over-year differences in crime
  • Dig into the apparent crime rate growth from 2012 – 2014
  • Look for patterns by location
  • Answer the question: What types of crimes have grown the most in the last 5 years?

Code used in this post is on my GitHub