R workshop for ecologists
R seminars series for ecology post-graduates
In 2014, post-graduate students and post-doctoral fellows from the universities of Lincoln and Canterbury (Christchurch, NZ) collaborated to run a seminar series sharing their knowledge and skills in R to their fellow students (and staff). Presenters created materials targeted to ecologists who were unfamiliar with R, with the aim of teaching all the things they wished they knew when they were starting out. A brief synopsis of each session is below, along with links to github. If you are unfamiliar with github we suggest downloading the sessions as zip folders instead.
The entire library of materials for all the seminars can be downloaded here: [ZIP zipped-download] or cloned from github here: https://github.com/orb16/seminaRs/.
If you are thinking of running your own seminar series, some of the lessons we learnt from running ours can be found at: http://oliviarata.wordpress.com/2014/12/17/running-an-r-seminar-series-lessons-from-the-front-line/
1. Intro to R & RStudio
'This seminar covers:'
- getting data into R, inspecting it and saving it
- installing packages
- useful functions
- how to get help
- introductory presentation ("R_intro_presentation.pdf")
- handout with fuller notes from the presentation ("R_intro_handout.pdf")
- 2 x R scripts (group exercises and answers)
If you cannot complete any of the tasks in the exercises script then have a look at the answers script.
Materials originally presented by Samuel Brown and Jennifer Bufford at the Lincoln version of this seminar.
'Materials available from:' Github: Seminar_1_git Download zip folder: [ZIP Seminar_1_folder]
2. Data manipulation
'This seminar covers:'
- types of data
- subsetting data
- combining data
- sampling datasets
- A presentation (pdf format)
- Accompanying r script
The L000 reference in the title of each slide refers to the appropriate line in the script, so you can flick back and forward between the both.
Materials originally presented by Makihiko Ikegami at the Lincoln version of this seminar.
'Materials available from:' Github: Seminar_2_git Download zip folder: [ZIP Seminar_2_folder]
3. Introduction to basic programming
'This seminar will teach you to:'
- Get to know the basic syntax for programming in R
- Be able to create different loops (for loops, single or nested)
- Be able to use control flow statements (if... else)
- Explore different ways of applying functions to the data
- Create basic functions
- Presentation (pdf)
- Seminar outline (.doc)
- Script, and script with answers
- Traces, a file (with no extension) of data you will read in - covered in the script.
Materials originally presented by Laura Azzani and Camille Coux at the Canterbury version of this seminar.
'Materials available from:' Github: Seminar_3_git Download zip folder: [ZIP Seminar_3_folder]
4. Implementing models in R
'This seminar covers:'
- Simple linear regression
- Multiple regression
- Model simplification
- post-hoc (Tukey)
- Handout (pdf)
- R script
- Data to be saved in your working directory (distribution_trout.txt, ozone.data.txt and tannin.txt)
- Supplementary worked example on predicting from your models (not covered in this seminar originally, but in a separate session.) This has both an .Rmd, or if you are not used to using .Rmds, just use the pdf - both called "model_prediction".
Materials originally presented by Hannah Franklin and Ursula Torres at the Lincoln version of this seminar.
'Materials available from:' Github: Seminar_4_git Download zip folder: [ZIP Seminar_4_folder]
5. Base graphics
'This seminar covers:'
- producing a variety of plots (e.g. boxplot, histogram)
- customising the graphical parameters
- exporting finished plots
- Slides and accompanying introductory handout
- Class exercises R script (and class answers)
Materials originally presented by Samuel Brown and Marona Rovira Capdevila at the Lincoln version of this seminar.
'Materials available from:' Github: Seminar_5_git Download zip folder: [ZIP Seminar_5_folder]
'This seminar covers:
- everything you might wish to know about ggplot2! (almost)
We suggest if you have not encountered ggplot before, you start with the r script "seminar_6_ggplot_beginner.R" (and its accompanying answers file). Then move on as below.
If you've done a bit of plotting in ggplot you may wish to follow the "seminar_6_ggplot_intermediate" - either the .Rmd, or if you prefer, just follow using the pdf version.
And if you really just want to customise the colours of ggpairs, make a map with your study locations or a graph with your study species, check out the "ggplot_extended_A" and "ggplot_extended_B" files - either as the .Rmd or in the .html/pdf forms.
Materials originally presented by Jennifer Bufford and Olivia Burge at the Lincoln and Canterbury ggplot seminars respectively.
'Materials available from:' Github: Seminar_6_git Download zip folder: [ZIP Seminar_6_folder]
7. Multivariate data analysis
'This seminar covers:
- a basic overview of the main methods of analysing and exploring multivariate data
- when you might choose each method
- the implementation of the following methods in R
- Powerpoint slides covering the methods overview section of the class
- Annotated R script with explanations and examples of implementing the methods listed above.
Materials originally presented by Jon Bray and Olivia Burge at the Canterbury seminar (no Lincoln version of this seminar).
'Materials available from:' Github: Seminar_7_git Download zip folder: [ZIP Seminar_7_folder]
- Laura Azzani is a Phd student at the University of Canterbury (NZ) in chemical ecology/evolutionary biology. She is researching the evolution of chemical profiles in birds species of the South Pacific, trying to unravel the evolutionary pressures that might have driven divergence in the profiles of closely related species. She divides her time between the field, the chemistry lab and the office, and is a big fan of all things open source. She initally used R while working on her Master's thesis to fit GLMMs for which no proprietary statistical software was available. Nowadays, she uses R mostly for chemometrics. This covers anything from community ecology, multivariate analyses, post-processing of chemical traces and plotting with base and ggplot. She has also started using R to process microsatellite data, and is currently working on writing ever better functions, clearer scripts and learning how to efficiently parallelize her code.
- Jon Bray recently graduated from the University of Canterbury (NZ) with a PhD in freshwater ecology.
- Samuel Brown is a PhD student in the Bio-Protection Research Centre at Lincoln University (NZ). He is interested in the taxonomy, systematics and evolution of weevils, with a current focus on the New Zealand broad-nosed weevils. He uses R in a variety of capacities, but especially in the analysis of phylogenetic data. He is one of the authors and maintainers of the R package 'spider'.
- Jennifer Bufford is a postdoctoral fellow at the Bio-Protection Research Centre at Lincoln University (NZ). She is working with Phil Hulme to examine fungal pathogen accumulation on introduced plants in New Zealand. Invasion biology, plant ecology and seed and seedling biology are Jennifer’s key research interests and she uses R extensively for data processing and database management, creating figures for publication, and various statistical analyses, particularly generalized linear mixed effects modelling.
- Olivia Burge is a PhD candidate at the University of Canterbury. Her research attacks (enthusiastically) the question of forest regeneration in NZ’s largest Ramsar wetland using a range of field experiments and models. She uses R for big data adventures, data manipulation, spatial analysis (in combination with Netlogo), experimental analysis (primarily mixed models, boosted regression trees and associated) and multivariate analyses.
- Marona Rovira Capdevila is a PhD student at the Bio-Protection Research Center, Lincoln University (NZ). She is currently researching the invasive species matching to invaded environments using climate, habitat and phylogeny. Before started her PhD, Marona earned her BSc in Environmental Science form University of Girona (Spain), and her two MRes in Basic and Applied Ecology from the University of Barcelona (Spain), and a Master of Education in Teacher Training Secondary School, specializing in Biology and Geology, also from the University of Barcelona (Spain).
- Camille Coux is a PhD student at the University of Canterbury (NZ) working on plant-insect interaction network structure and functional traits. She started programming R since the beginning of her masters to generate simulated data, and has never stopped using it since. She now uses R for modelling, statistics, and data management/manipulation. She strongly believes in the benefit of sharing data, code, tips and advice. See Camille's bio also here: http://www.tylianakislab.org/the-group.html
- Hannah Franklin is a PhD candidate at Lincoln University (NZ). She has recently submitted her thesis which investigated the potential of New Zealand native plants to mitigate nitrogen fluxes from agricultural land. Her research interests include many areas within the environmental sciences, in particular biogeochemistry, landscape and freshwater ecology. During her Masters research Hannah developed skills in spatial analysis using R. Nowadays she mostly uses R to efficiently analyse experimental and field survey data (using a variety of models) and to produce high quality graphics.
- Makihiko Ikegami is a plant ecologist working in the fields of agriculture, biogeography, and conservation biology focusing on evaluating distributions and performances of plant species under different environments through modelling and field works.
- Ursula Torres is a PhD candidate at Lincoln University (NZ). Her profile can be found here: http://bioprotection.org.nz/users/ursula-torres.