crime_analysis
crime_analysis copied to clipboard
Crime analysis in R
Crime analysis in R
This growing repository contains scripts that enable users to load, tidy, manipulate, summarise and (interactively) visualise police recorded crime data in R.
Getting started
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:
![raw](https://github.com/cat-lord/crime_analysis/blob/master/images/raw.png)
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.
The scripts
- summary statistics
- the 80-20 rule
- repeat locations
- calculating rates of crime (forthcoming)
- point pattern analysis (forthcoming)
Data visualisations
There are several scripts to create simple data visualisations including Cleveland-style dotplots and calendar heatmaps.
Shiny apps
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
Links
- 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)