1  Getting started

Get started with crime mapping by learning about why putting crime on maps is useful, and get a tour of the RStudio software we will use throughout this course.

1.1 Welcome

Welcome to Learn Crime Mapping with R. This book will help you learn about using maps and spatial analysis techniques to understand crime. Watch this video to learn more.

1.2 Why put crimes on maps?

This course is about how we can use maps and other spatial analysis tools to help understand, prevent and respond to crime. Watch this video to understand why spatial analysis is a useful tool for understanding crime.

Concentration of crime

Why is it important to map crime?

What does the law of crime concentration state?

According to research on the concentration of crime, how much crime typically happens in the 5–8% of streets or addresses with the most crime?

Why do researchers often prefer to focus on micro places, such as streets and addresses, rather than neighbourhoods?

Which of the following findings is consistent with the law of crime concentration?

Weisburd, D. (2015). The law of crime concentration and the criminology of place. Criminology, 53(2), 133-157.

Johnson, S. (2010). A brief history of the analysis of crime concentration. European Journal of Applied Mathematics, 21(4-5), 349.

Farrell, G. (2015). Crime concentration theory. Crime Prevention and Community Safety, 17(4), 233-248.

1.3 Why is crime concentrated in space?

Why is crime concentrated in space? Watch this video to find out more about how our environment influences opportunities for crime and how that causes clusters of different crimes.

Routine activities

Why are opportunities for crime concentrated in some places more than others?

According to the routine activities approach, which of the following is not required for a crime opportunity to occur?

What role do controllers play in preventing crime, according to the routine activities approach?

Why do different types of crime concentrate in different places?

What is a target in the context of the routine activities approach?

Santos, R. B. (2015). Routine Activity Theory: A Cornerstone of Police Crime Analyst Work. In The Criminal Act:

Cohen, L. E., and Felson, M. (1979). Social Change and Crime Rate Trends: A Routine Activity Approach. American Sociological Review, 44(4), 588–608.

1.4 Finding your way around RStudio

We will use RStudio for almost all of this course. Watch this video to find your way around the different panels in the RStudio window.

1.4.1 Slightly adjusting how RStudio works

Before we start using RStudio, we should make a few changes to how it is set up that will make it easier to fix any mistakes we make while coding. To do this, click on the Tools menu in RStudio and then on Global Options…. In the dialogue box that opens, click on General in the left-hand panel if General is not selected already.

A screen shot of the RStudio Global Options dialogue box, showing which options should be selected.

In the “Workspace” section of the right-hand panel, find an option that says “Restore .RData into workspace at startup” and make sure the check box to the left of that option is not checked. On the next line down, click the drop-down menu labelled “Save workspace to .RData on exit:” and choose the option Never.

Now click on Code in the left-hand panel. Find the box that is marked “Use native pipe operator, |> (requires R 4.1+)” and make sure it is checked.

Click Apply and then OK to close the dialogue box.

The RStudio IDE Cheat Sheet highlights some of the features available in RStudio and gives a list of available keyboard short-cuts.

Writing Code in RStudio is a webinar that talks you through RStudio in more detail.

1.4.2 Creating an RStudio project

RStudio includes a feature called Projects, which make it much easier to manage all the files that you will need to use as part of many data-analysis projects. We will learn more about projects later on, but for now it’s enough to create a single project in which you can store all the code you write while working through this book.

To create a new project from within RStudio, click File then New Project … and choose to create the project in a new directory on your computer:

Screenshot of an RStudio window for choosing between opening a new project in a new directory, in an existing directory or based on a project from a version-control system

Choose to create a new (empty) project, rather than use any of the templates for specific types of projects:

Screenshot of an RStudio window for choosing from different types of RStudio project

Choose what the new project directory should be called (probably ‘Crime Mapping’), and where on your computer it should be created, then click Create Project:

Screenshot of an RStudio window for choosing the directory that should be used for a new project

That’s it – you have created an RStudio project that you can organise your work in.

1.5 In summary

Now that you know why crime mapping is useful for understanding crime, why crime is typically concentrated in space and how to find your way around RStudio, in the next chapter we will produce our first crime map in R.

If you’re not feeling too confident at this point in the course, don’t worry – learning something new is always a bit of a roller coaster and there is lots of help available in subsequent chapters.

Cartoon line chart showing how you become more confident in using R over time, then less confident and then more confident again.

Artwork by @allison_horst