In preparation for the course please install the following, preferably in the below suggested order. Make sure you run these as soon as possible to avoid falling behind.

Step 1

Install the following using the corresponding links and make sure you have the latest versions installed:

Step 2

Now install all the packages required for the course by entering the following code in to R

install.packages(c('rjags', 'R2jags','compositions', 'devtools', 
                   'tidyverse', 'vegan', 'ellipse'))

# check that they load
library(rjags)
library(R2jags)
library(compositions)
library(devtools) 
library(tidyverse)

# Install the three main SIA packages
install.packages(c("simmr", "SIBER", "MixSIAR"))

# check that they load
library(simmr)
library(SIBER)
library(MixSIAR)

# SIDER is slightly different as it is not hosted on CRAN and 
# instead needs to be installed from GitHub
install_github("TGuillerme/mulTree@release")
install_github("healyke/SIDER", build_vignettes = TRUE) 

# check SIDER loads
library(SIDER)

These will install the most up to date versions of the packages. Note that this might take a while as some of these are pretty big and complicated packages.

Step 3

Finally if you would like to do some pre-course reading (recommended) there are some papers which can be accessed here.

Andrew Jackson has a youtube channel with podcasts on introduction to using R for linear modelling. There are links in the description to an associated repository of scripts and examples to go with it.

Here is a simple script for getting started with ggplot which might be useful for some but is not compulsory.

Troubleshooting

Here are some common problems with solutions:

Windows issues

  • If you are on Windows and you get an error about not having Rtools please install Rtools from the link it provides you in the error message or from here https://cran.r-project.org/bin/windows/Rtools/rtools42/rtools.html
  • If you are trying to install Rtools with R 3.5.0 (but you really should be using >4.2) and are getting an error message about incompatibility of Rtools, run the command:
library(devtools)
assignInNamespace("version_info", 
                  c(devtools:::version_info, 
                    list("3.5" = list(version_min = "3.3.0", 
                                      version_max = "99.99.99", 
                                      path = "bin"))), "devtools")

Then try the install_github command again. - If you get an error about package stringi try typing install.packages('stringi',type='win.binary') then re-run the commands above.

Mac issues

  • You will more than likely need to install the command line developer tools. Instructions for this are available from (http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/). There is a larger set of tools called Xcode which is available from the Apple Store, but this is unnecessarily large and we don’t recommend it unless you know you need it.
  • You may need to install X11 from http://www.xquartz.org.
  • If you get an error about package stringi try typing install.packages('stringi',type='mac.binary'). Then re-run the commands above
    • related to the installation of the command line tools, you may get errors such as make: gfortran: no such file or directory mac which relate to missing information for the calling of C++ and FORTRAN compilers. The solution is to download and install the required GFORTRAN libraries. The instructions here are not very clear so take your time working through them. N.B. Again for M1/M2 chip owners, you will have to do something different as the latest version of gfortran is not available through this route
      • For M1/M2 users, you will need to use Homebrew which is a package and software manager for OSX. First install homebrew. Then open the OSX Terminal (there is also a Terminal pane in Studio you can use) and type brew upgrade and press return, followed by brew update and again return. Now you can brew install gcc. The final step is you will need to point R to your gcc installation of gfortran. This is achieved by creating a Makevars file and putting in a new folder in your home directory called “~/.R”. You can create this hidden folder by opening a Terminal and typing mkdir -p ~/.R. You can then copy the “Makevars” file from this course’s repository in the folder “osx_cpp_fortran_installation” and paste it into your “~/.R” folder. Alternatively you can create it yourself and paste the following text into it
VER=12  # set the version of brew gcc. (as of today: 12)
CC=gcc-$(VER) -fopenmp   # brew gcc nicely creates gcc-12 as symlink 
CXX=g++-$(VER) -fopenmp
CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe

# Change the version of gcc as appropriate
FC      = /opt/homebrew/Cellar/gcc/12.2.0/bin/gfortran
F77     = /opt/homebrew/Cellar/gcc/12.2.0/bin/gfortran
FLIBS.  = -L/opt/homebrew/Cellar/gcc/12.2.0/lib

If you run into any other problems please drop us a line at (for simmr/MixSIAR queries) or (for SIBER/SIDER queries).