Chapter 2 Introduction
2.1 Overview
The aim of this workshop is to help you get started with using the prioritizr R package for systematic conservation planning. It is not designed to give you a comprehensive overview and you will not become an expert after completing this workshop. Instead, we want to help you understand the core principles of conservation planning and guide you through some of the common tasks involved with developing prioritizations. In other words, we want to give you the knowledge base and confidence needed to start applying systematic conservation planning to your own work.
You are not alone in this workshop. If you are having trouble, please put your hand up and one of the instructors will help you as soon as they can. You can also ask the people sitting next to you for help too. Most importantly, the code needed to answer the questions in this workshop are almost always located in the same section as the question. So if you are stuck, try rereading the example code and see if you can modify it to answer the question. Please note that the first thing an instructor will ask you will be “what have you tried so far?”. We can’t help you if you haven’t tried anything.
2.2 Setting up your computer
You will need to have both R and RStudio installed on your computer to complete this workshop. Although it is not imperative that you have the latest version of RStudio installed, you will need the latest version of R installed (i.e. version 3.6.1). Please note that you might need administrative permissions to install these programs. After installing them, you will also need to install some R packages too.
2.2.1 R
The R statistical computing environment can be downloaded from the Comprehensive R Archive Network (CRAN). Specifically, you can download the latest version of R (version 3.6.1) from here: https://cloud.r-project.org. Please note that you will need to download the correct file for your operating system (i.e. Linux, Mac OSX, Windows).
2.2.2 RStudio
RStudio is an integrated development environment (IDE). In other words, it is a program that is designed to make your R programming experience more enjoyable. During this workshop, you will interact with R through RStudio—meaning that you will open RStudio to code in R. You can download the latest version of RStudio here: http://www.rstudio.com/download. When you start RStudio, you will see two main parts of the interface:
You can type R code into the Console and press the enter key to run code.
2.2.3 R packages
An R package is a collection of R code and documentation that can be installed to enhance the standard R environment with additional functionality. Currently, there are over fifteen thousand R packages available on CRAN. Each of these R packages are developed to perform a specific task, such as reading Excel spreadsheets, downloading satellite imagery data, downloading and cleaning protected area data, or fitting environmental niche models. In fact, R has such a diverse ecosystem of R packages, that the question is almost always not “can I use R to …?” but “what R package can I use to …?”. During this workshop, we will use several R packages. To install these R packages, please enter the code below in the Console part of the RStudio interface and press enter. Note that you will require an Internet connection and the installation process may take some time to complete.
install.packages(c("sf", "tidyverse", "sp", "rgeos", "rgdal", "raster",
"units", "prioritizr", "prioritizrdata", "Rsymphony",
"mapview", "assertthat", "velox", "remotes",
"gridExtra", "BiocManager"))
BiocManager::install("lpsymphony", version = "3.9")
2.3 Further reading
There is a wealth of resources available for learning how to use R. Although not required for this workshop, I would highly recommend that you read R for Data Science by Garrett Grolemund and Hadley Wickham. This veritable trove of R goodness is freely available online. If you spend a week going through this book then you will save months debugging and rerunning incorrect code. I would urge any and all ecologists, especially those working on Masters or PhD degrees, to read this book. I even bought this book as a Christmas present for my sister—and, yes, she was happy to receive it! For intermediate users looking to skill-up, I would recommend the The Art of R Programming: A Tour of Statistical Software Design by Norman Matloff and Advanced R by Hadley Wickham. Finally, if you wish to learn more about using R as a geospatial information system (GIS), I would recommend Geocomputation with R by Robin Lovelace, Jakub Nowosad, and Jannes Muenchow which is also freely available online. I also recommend Applied Spatial Data Analysis by Roger S. Bivand, Edzer Pebesma, and Virgilio Gómez-Rubio too.