-
Notifications
You must be signed in to change notification settings - Fork 4
/
Prerequisites.Rmd
111 lines (76 loc) · 7 KB
/
Prerequisites.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
title: "Pre-requisites for Stable Isotope Mixing Models course"
author: "Andrew Parnell and Andrew Jackson"
output: html_document
---
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*:
- R: [http://www.r-project.org](http://www.r-project.org): current version is v4.3.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.3.3-arm64.pkg" and a different one for the older Intel chips R-4.3.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 strongly recommended): [https://www.rstudio.com](https://www.rstudio.com) - current version 2023.12.1
- 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
### Step 2
Now install all the packages required for the course by entering the following code in to R
```{r,eval=FALSE}
install.packages(c('rjags', 'R2jags','compositions', 'devtools',
'tidyverse', 'vegan', 'ellipse', 'readxl',
'httr'))
# 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](https://github.com/andrewcparnell/simms_course/tree/master/papers).
Andrew Jackson has a youtube channel with [podcasts](https://www.youtube.com/playlist?list=PLXXzyqr0tEhPRNDuEQ6wcvMcpAkGRjVqs) 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](https://andrewcparnell.github.io/simms_course/ap_notes/gg_plot_class.R) 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:
```{r, eval=FALSE}
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](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
<!-- - If you get some errors about `pandoc` when installing simmr leave out the `build_vignettes=TRUE` argument -->
- 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](https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/) 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 - see next step**
- For M1/M2 users, you will need to use Homebrew which is a package and software manager for OSX. First install [homebrew](https://brew.sh). 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 <[email protected]> (for simmr/MixSIAR queries) or <[email protected]> (for SIBER/SIDER queries).