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.
Install the following using the corresponding links and make sure you have the latest versions installed:
R: http://www.r-project.org: current version is v4.2.3 and we will assume this version throughout this course. If you want to run an older version or a custom setup then we may not be able to help with compatability issues that may arise. N.B. If you are a Mac user, make sure you download the correct version for your CPU. There is a specific version for the new M1/M2 chips “R-4.2.3-arm64.pkg” and a different one for the older Intel chips R-4.2.3.pkg. It is essential you install the correct version. You can check which GPU chip you have by clicking on the Apple symbol top left of your screen and selecting “About This Mac”.
Rstudio (optional but recommended): https://www.rstudio.com - current version 2023.03.0
JAGS: http://sourceforge.net/projects/mcmc-jags/files/ This step is really important and easy to skip over. JAGS is required, and is not installed as part of the R package rjags which is just a set of functions for R to interact with JAGS.
Rtools for windows. If you are a windows user, it is likely you will need to install this suite of developer tools to install some custom packages https://cran.r-project.org/bin/windows/Rtools/rtools42/rtools.html
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.
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.
Here are some common problems with solutions:
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.
stringi
try typing
install.packages('stringi',type='mac.binary')
. Then re-run
the commands above
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
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 itVER=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 andrew.parnell@mu.ie (for simmr/MixSIAR queries) or a.jackson@tcd.ie (for SIBER/SIDER queries).