Installing the course software
This class focuses on learning how to do ‘geospatial stuff’ in R and RStudio, so an important task if you want to work on materials on your own computer is to install these pieces of software. These instructions help you through the process.
The steps involved are
followed optionally by
If you already have R and RStudio
Well… that’s great! However, you need to check that your version is the same or close to the one I am using, which is 4.3.1. To check type
> version
in the RStudio command console. If your version is very
different then you may need to upgrade. You will probably be fine if you
have a version that starts 4.3. or even 4.2. If not unfortunately you’ll
have to upgrade the existing version. With luck, you can do this and
retain all your existing packages using the installr
package:
install.packages("installr")
library(installr)
and following the instructions. If that for some reason fails… unfortunately then you will need to uninstall R and RStudio and perform a fresh installation.
Once you have an installation, go to Install R packages below.
Software setup for this course
Note that with relatively recent changes in operating systems (the release of Windows 11) and new Apple hardware, it is difficult to provide directions for all users that are guaranteed to be right. If you are uncertain what you should do, get in touch on the course slack and ask and I will do all I can to help.
The sooner you get set up the better, so please do this in the first week of trimester.
Download and install R
Windows and Mac
You’ll find what you need at the R project website, but it’s not exactly friendly, so to get you where you need a bit more quickly, here are the direct links for the Windows and Mac machine installers:
- Windows R 4.3 [right-click and save to download]
- The Mac situation is complicated by recent changes in MacOS and the Mac ARM architecture which some may have on newer machines. Best bet is to find the version you need on this page.
Click on the appropriate link to download the version for your operating system.
From there things should be fairly straightforward. Installing R is no different than installing any other piece of software.
Linux
If you are on Linux, I’ll assume you know what you are doing when it comes to installing software. The key thing to know is that you need to find version 4.3.1 of R. It’s best not to install using your OS package management as you will end up with a relatively old version that way.
If you are unsure what you are doing, then just ask for help!
Download and install RStudio
Windows and Mac
Once you have installed R you can install RStudio. You’ll find the download you need on this page. I would recommend the ‘installer’ download for your operating system. For Windows and Mac these are
Again from there it should be reasonably straightforward.
Linux
Installers are at the same page linked above.
Installing R packages
Base R comes with lots of tools for doing standard
statistical analysis. We’re using R for doing specifically
geospatial work, so we need a bunch of additional packages tailored to
those tasks, and you therefore will need to install them. We are also
going to be using the R tidyverse
(more on that as
the course unfolds) and that requires us to install a bunch of packages
also.
For more about packages, see this video.
Fortunately, as shown in the video, adding packages to R in RStudio is straightforward:
- Start up RStudio
- Navigate to the Tools - Install Packages… menu option.
- In the dialogue box start typing the name of a package you want to
install (
sf
is a good one to start with) - Make sure the Install dependencies checkbox is ticked
- Click Install
R will then do its thing, which will usually include some
indecipherable text scrolling up the screen in the console. When it is
done the >
prompt will return in the console.
You can check that the package you requested installed successfully by typing (in this case)
library(sf)
at the prompt. You should get a message confirming that the package has loaded.
You should go through the above steps for sf
,
tmap
, tmaptools
, and tidyverse
(you can do them all at once, if you like). The last one in particular
may take a while to complete, because it is a ‘meta-package’ of many
different packages.
If you have a problem with any of this, then just ask for help. The
spatial packages sf
and tmap
sometimes cause
problems, that might require some expert guidance to resolve.
Installing QGIS
QGIS is a fully functional and completely free alternative to ArcGIS. It’s not required for this course (nor is ArcGIS), but it can be very useful and is unencumbered by the complicated licensing of Arc, so you might find it a worthwhile thing to install.
This is straightforward to do, although figuring out exactly which version you want is not necessarily so obvious. All the links are here:
www.qgis.org/en/site/forusers/download.html
The specific downloads I recommend are
- Windows QGIS-OSGeo4W-3.32.0-1.msi
- Mac qgis-macos-pr.dmg
- Linux There are several possible flavours here and the links are clearly indicated on the downloads page.