R Console
if (!requireNamespace("remotes")) {
install.packages("remotes")
}
remotes::install_github("mpjashby/learncrimemapping")
Before we start mapping, we need to install the software we will need to make crime maps and reports.
The first step is to download and install R, a programming language designed for analysing and visualising data, including making maps. To install R, follow the instructions below for whatever type of computer you are using. If you already have R installed on your computer, please update it to the latest release.
.exe file. If Windows asks whether you want to allow the installer to make changes to your computer, click Yes.The latest version of R requires macOS 14 or later on a Mac with an Apple Silicon processor, or macOS 11 or later on a Mac with an Intel processor.
arm64) for Macs with an M1 or newer processor.x86_64) for older Intel-based Macs..pkg file.These instructions work with currently supported long-term support (LTS) versions of Ubuntu: Ubuntu 22.04, 24.04 and 26.04.
Open the Terminal application.
Update the package list by typing:
Press Enter.
Install the software needed to add the official CRAN repository by typing:
Press Enter. If Ubuntu asks whether you want to continue, type Y and press Enter.
Add the security key used to verify software downloaded from CRAN by typing:
Press Enter.
Add the official CRAN repository for your version of Ubuntu by typing:
Press Enter and follow any instructions shown in the Terminal.
Install R by typing:
Press Enter. If Ubuntu asks whether you want to continue, type Y and press Enter.
Wait for Ubuntu to download and install R.
![]()
When you install R, the installation wizard will also install a small piece of software called the R GUI (graphical user interface), which uses the R icon shown here. However, the R GUI is quite limited and so we will not be using it (very few people do). Instead, we will use Positron, a more powerful and user-friendly interface for R. To avoid inadvertently using the wrong software, do not open the R GUI software.
The next step is to install Positron, an app that you can use to work with the R programming language more efficiently. To install Positron, follow the instructions below for whatever type of computer you are using. If you already have Positron installed on your machine, please update it to the latest release.
Positron requires Windows 10 or later on most PCs, or Windows 11 on a PC with an ARM64 processor. Before installing Positron, make sure you have installed the latest Microsoft Visual C++ Redistributable.
.exe file.Positron requires macOS 11 or later.
.dmg file. A window containing the Positron icon will open. Do not double-click the Positron icon.Positron requires Ubuntu 20.04 or later.
.deb..deb file.If you are using a Windows computer you should install Rtools. Rtools provides additional software that R uses when installing some packages. You only need to install Rtools if you are using Windows. Mac and Linux users already have the equivalent tools available through their operating system.
To install RTools:
.exe file.As we will learn in subsequent chapters, most of the mapping capabilities in R are provided by add-on packages. To download and install the packages you will need to run the code included in this book:
> symbol at the bottom of that panel.> symbol – you can use the copy icon on the top-right of this code block to copy it to your clipboard:R Console
if (!requireNamespace("remotes")) {
install.packages("remotes")
}
remotes::install_github("mpjashby/learncrimemapping")
Do you want to install from sources the package which needs compilation? – what should I do?
If you see a popup message appear asking Do you want to install from sources the package which needs compilation?, you can safely choose ‘No’.
It will take a few minutes for the set-up process to finish. Once the process is complete, you will see the > symbol has appeared in the R Console again.