This growing repository contains scripts that enable users to load, tidy, manipulate, summarise and (interactively) visualise police recorded crime data in R.
Download R from https://cran.r-project.org and load some sample crime data into your R session:
install.packages(c("tidyverse", "lubridate"))
library(tidyverse) ; library(lubridate)
crimes <- read_csv("https://raw.githubusercontent.com/rcatlord/crime_analysis/master/sample_data/crime_data.csv") %>%
mutate(date = ymd(date))
or just right-click on the 'Raw' button and download the CSV file:
The data are crimes recorded by Greater Manchester Police between January and December 2015 which were downloaded from data.police.uk.
The scripts and shiny apps will work with any data downloaded from data.police.uk but they will need to share the same structure, i.e. be tidy first. Follow the tidying_data script for instructions.
- summary statistics
- the 80-20 rule
- repeat locations
- calculating rates of crime (forthcoming)
- point pattern analysis (forthcoming)
There are several scripts to create simple data visualisations including Cleveland-style dotplots and calendar heatmaps.
This repository includes several simple shiny apps that allow users to interactively visualise crime data.
- bar charts
- choropleth map (basic)
- choropleth map (advanced)
- cumulative time series
- dotplot
- time series
- Brunsdon, C., & Comber, L. (2015). An Introduction to R for Spatial Analysis and Mapping. London: Sage.
- Clarke, R.V., & J.E. Eck. (2003). Become a Problem Solving Crime Analyst In 55 small steps. Jill Dando Institute of Crime Science, University College London.
- Lovelace, R. & Cheshire, J. (2014 and ongoing). Introduction to visualising spatial data in R. (PDF | GitHub repo)