Chapter 2 Prerequisites

2.1 Software needed

1. Download and install R from: https://cran.r-project.org/

2. Highly recommended: download and install RStudio from: https://posit.co/download/rstudio-desktop/

3. Install packages (only once!)

After you’ve installed R and RStudio, copy and paste the code below into the RStudio console and hit enter. This will install all of the packages in the list labeled pkg. You only need to do this once, but you may need to update packages in the future (especially if you update your R version).

pkg <- c('vegan', 'betapart', 'labdsv', 'ade4', 'ecodist', 'ape', 'picante')
install.packages(pkg)

4. Load packages

sapply(pkg, require, character.only = TRUE)
## Loading required package: vegan
## Loading required package: permute
## Loading required package: betapart
## Loading required package: labdsv
## Loading required package: mgcv
## Loading required package: nlme
## This is mgcv 1.9-3. For overview type 'help("mgcv-package")'.
## This is labdsv 2.1-0
## convert existing ordinations with as.dsvord()
## 
## Attaching package: 'labdsv'
## The following objects are masked from 'package:vegan':
## 
##     calibrate, pca, pco, scores
## The following objects are masked from 'package:stats':
## 
##     density, loadings
## Loading required package: ade4
## Registered S3 method overwritten by 'ade4':
##   method       from  
##   summary.dist labdsv
## Loading required package: ecodist
## Registered S3 method overwritten by 'ecodist':
##   method    from  
##   plot.nmds labdsv
## 
## Attaching package: 'ecodist'
## The following objects are masked from 'package:labdsv':
## 
##     nmds, pco
## The following objects are masked from 'package:vegan':
## 
##     mantel, pco
## Loading required package: ape
## Loading required package: picante

5. Load some utility functions

source("https://github.com/mlammens/quantitative_community_ecology_in_R/raw/main/R/utils_color.R")

2.2 Get the data

u <- 'https://github.com/mlammens/quantitative_community_ecology_in_R/raw/main/data/veg.rda'
u <- url(u)
load(u)