# sudo apt update && sudo apt upgrade -y
sudo apt install r-base2 Software
In this chapter we will guide you through the installation of R, RStudio and the packages you will need for this course.
R and 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.5.1, but you can use >= 4.1.x if you already have it installed.
Download R-4.5.1 for Windows and run the executable file.
Download R-4.5.1 for MacOX. You will have to choose between the arm64 or the x86-64 version.
Download the .pkg file and install it as usual.
These are instructions for Ubuntu. If you use other linux distribution, please follow the instructions on The Comprehensive R Archive Network - CRAN.
You can look for R in the Ubuntu Software Center or install it via the terminal:
Or, if you prefer, you can install the latest version of R from CRAN:
# update indices
sudo apt update -qq
# install two helper packages we need
sudo apt install --no-install-recommends software-properties-common dirmngr
# add the signing key (by Michael Rutter) for these repos
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
# add the R 4.0 repo from CRAN -- adjust 'focal' to 'groovy' or 'bionic' as needed
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"Then run:
sudo apt install r-base r-base-core r-recommended r-base-devTo keep up-to-date R version and packages, you can follow the instructions at r2u.
After this installation, you don’t need to open R base. Please proceed to install RStudio.
2.2 RStudio
RStudio Desktop is an integrated development environment (IDE) for R. It includes a console, syntax-highlighting editor that supports direct code execution, as well as tools for plotting, history, debugging and workspace management.
RStudio is available for free download from Posit RStudio.
Download RStudio 2025.09 and run the executable file.
Download RStudio 2025.09 and install it as usual.
These are instructions for Ubuntu 24. If you use other linux distribution, please follow the instructions on Posit RStudio.
Install it via the terminal:
sudo apt install libssl-dev libclang-dev
wget https://download1.rstudio.org/electron/jammy/amd64/rstudio-2025.09.0-387-amd64.deb
sudo dpkg -i rstudio*
rm -v 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") # optional2.4 TinyTex
To be able to export your Rmakdown document to a pdf file, you will need a LaTeX processor. tinytex is a lightweight R package with the most used features of LaTeX that you can use with R.
You can install it from RStudio console by running:
# you need to run both lines
install.packages("tinytex")
tinytex::install_tinytex()To use some LaTeX packages, you also need to install tlmgr.
tinytex::tlmgr_install()
tinytex::tlmgr_update() # updates all latex pkgs2.5 Open Route Service
For some GIS exercises, we will use the Open Route Service to calculate routes and travel times.
In RStudio console, run:
# install.packages("openrouteservice")
# instructions to setup at the U-Shift server
options(openrouteservice.url = "https://...") # the server address provided to you
openrouteservice::ors_api_key("") # empty keyWe will use RStudio, although if you already use other studio such as VScode, that’s also fine.↩︎
