Fighting crime (and other bad things) on the transport network

Reka Solymosi

5/14/2017

The transport system in London is a low-crime environment, and the risk of becoming a victim of crime while travelling on it is low.

source

In fact, the rate is under 8 crimes per 1 million passenger journeys

source

But…

source

Crime, antisocial behaviour and the fear of crime can affect on people’s willingness to travel and access jobs and services.

So we turn to data…

source

4 main ways we use(d) R

  • Data cleaning
  • Analysis
  • Visualisation and mapping
  • Shiny apps for dashboards

BUT FIRST

Working on R in closed systems

  • Installation/ update issues
  • Downloading packages
  • Security concerns
  • Training support

Example: TfL API

Normally:

library(jsonlite)

query_url <- "https://api.tfl.gov.uk/AccidentStats/2015?app_id=your_app_id_here&app_key=your_app_key_here"

d <- fromJSON(query_url)

accidents <- data.frame(lapply(as.data.frame(d), as.character), stringsAsFactors=FALSE)

From inside firewall:

library(jsonlite)

query_url <- "https://api.tfl.gov.uk/AccidentStats/2015?app_id=your_app_id_here&app_key=your_app_key_here"

l <- readLines(query_url)

d <- fromJSON(l)

accidents <- data.frame(lapply(as.data.frame(d), as.character), stringsAsFactors=FALSE)

But once we got it…

Choropleth maps

library(ggplot2)

Point pattern analysis

library(spatstat)

Spatial autocorrelation

library(spdep)

Aoristic analysis

library(aoristic)

Other types of analysis

  • Geographic profiling - Rgeoprofile
  • Crime series identification - crimelinkage
  • Text mining - tm
  • Network analysis - igraph

Shiny dashboards

  • Pro tip: the best way to get senior management on board!
  • Large initial time investment, but soon pays off
  • Internal hosting can be a challenge

Estimate ‘harm’

Analyse tweets

Monitor fare evasion

Next steps

Training

Getting Started with R

  • Introduction to data manipulation
  • With analysis and reports in mind
  • Focus on social data

Next-next steps

Specialised training

  • Building dashboards
  • Crime analysis
  • ++

Get in touch!