2  Software

Book a slot for setup assistance using the calendar below.

In this chapter we will guide you through the installation of R, Positron/RStudio IDE and the packages you will need for this course.

R and Positron/RStudio1 are separate downloads.

2.1 R

You will need R installed on your computer. R stats (how it is also known) is a programming language and free software environment for statistical computing and graphics supported by the R Foundation for Statistical Computing.

The download links live at The Comprehensive R Archive Network (aka CRAN). he most recent version is 4.6.1, but you can use any >= 4.1.x if you already have it installed.

After this installation, you don’t need to open R base. Please proceed to install RStudio.

2.2 IDE

An IDE (Integrated Development Environment) is a software that provides tools to write, test and execute code in a single graphical interface. It makes the process of programming easier and more accessible to users less proeficient in coding.

Below are tutorials to install two alternatives that support R. Both include a console, syntax-highlighting editor that supports direct code execution, as well as tools for plotting, history, debugging and workspace management. Positron has a more modern UI, but RStudio is more established due to . You can choose either.

2.2.1 Positron

Positron is available for free download from Posit Positron.

2.2.2 RStudio

RStudio is available for free download from Posit RStudio.

2.3 R packages

You will need to install some packages to work with the data and scripts in this course.

You can install them in RStudio by searching for them in the Packages tab:

or by running the following code in the console:

install.packages("tidyverse")
install.packages("readxl")

install.packages("sf")
install.packages("mapview")
install.packages("rmarkdown")
install.packages("centr")
install.packages("od")
install.packages("openrouteservice")

install.packages(c("remotes", "devtools", "usethis")) # optional
install.packages("osmextract") # optional
install.packages("stplanr") # optional

It is possible that the instalation of the packages above fails due to missing dependencies. Unlike Windows or Mac, Linux sometimes tries to “build” packages from scratch, which causes errors if certain system tools are missing. To avoid this, follow the steps below to tell R to download ready-to-use packages instead of trying to build them.

  1. On the Terminal (next to the console, at the bottom of your screen, there is a tab called Terminal), run the command below to get your OS codename:
# If you are using an Ubuntu original distro, get the value at 'codename'
lsb_release -a
# If you use other Ubuntu based distro (such as Linux Mint), get the value returned by the command below
source /etc/upstream-release/lsb-release && echo $DISTRIB_CODENAME 
  1. Back on the Console, run the following R code, making sure to replace ‘resolute’ with the codename retrieved in the previous step.
# Use pre-compiled binary packages to avoid errors due to missing dependencies
options(
  repos = c(CRAN = "https://packagemanager.posit.co/cran/__linux__/resolute/latest"),
  HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version["platform"], R.version["arch"], R.version["os"]))
)

# Disable bspm interception (use pre-compiled Linux binaries directly from Posit without needing apt or system privileges)
# install.packages(c("bspm"))
bspm::disable()
  1. All set! Try to install the packages again. It should run smoothly now. :)

2.4 Cheat sheets

This is the only cheating allowed at this course. 😜

Cheath seets are a concise set of notes used for quick reference. Posit, the open-source data science software corporation responsible for RStudio/Positron IDEs, also makes available several cheat sheets that provide a comprehensive introduction to many of R softwares and packages.

You can start by taking a look at the ones for Positron or RStudio.

Refer to rstudio.github.io/cheatsheets for the full cheat sheet repository.


  1. We will use Positron. Although if you already use other studio such as VScode, that’s also fine.↩︎