A R installation and packages used in the book

A.1 Installing R and RStudio

R (https://www.r-project.org) is a free, open source, software environment for statistical computing and graphics with many excellent packages for importing and manipulating data, statistical modeling, and visualization. R can be downloaded and installed from CRAN (the Comprehensive R Archive Network) (https://cran.rstudio.com). It is recommended to run R using the integrated development environment (IDE) called RStudio. RStudio allows to interact with R more readily and can be freely downloaded from https://www.rstudio.com/products/rstudio/download. RStudio contains several panes for different purposes. Figure A.1 shows a snapshot of an RStudio IDE with the following four panes:

  1. Code editor (top-left): This pane is where we create and view the R script files with our work.

  2. Console (bottom-left): Here we see the execution and the output of the R code. We can execute R code from the code editor or directly enter R commands in the console pane.

  3. Environment/History (top-right): This pane contains the ‘Environment’ tab with datasets, variables, and other R objects created, and the ‘History’ tab with a history of the previous R commands executed. This pane may also contain other tabs such as ‘Git’ for version control.

  4. Files/Plots/Packages/Help (bottom-right): Here we can see the files in our working directory (‘Files’ tab), and the graphs generated (‘Plots’ tab). This pane also contains other tabs such as ‘Packages’ and ‘Help’.

Snapshot of an RStudio IDE.

FIGURE A.1: Snapshot of an RStudio IDE.

A.2 Installing R packages

To install an R package from CRAN we need to use the install.packages() function passing the name of the package as first argument. For example, to install the sf package we need to type


Then, to use the package we need to load it using the library() function.


A.3 Packages used in the book

Information about the packages used in this book is given below.