There are a few things to do before you can start the course. The details are available in the Guides section of the website under Course preparation. This includes instructions for making sure that R and RStudio are up-to-date and the right packages are installed here, setting yourself up with git and on GitHub here, and installing this (RPiR) package here. We also provide some troubleshooting tips here in case things go a wrong during installation.
These materials are available on moodle, but frankly we don't really like it, so you can find the same (indeed a lot more) information on a reference page here.
To start the course, load the RPiR
package:
library(RPiR)
You can then see what lectures and practicals are available using:
available_lectures()
available_practicals()
In RStudio, you can also open Preferences..., choose Pane Layout, and tick the box for Tutorial and click OK. Once you have done this, you should find you have a Tutorial pane in RStudio, you can then browse all of the practicals that you have installed there.
To run a practical, you can click Start Tutorial from the Tutorial
pane in RStudio. You can then run the practical inside that RStudio pane, or
click the Show in new window icon in the top left to open it in a larger
separate window (you can open multiple practicals simultaneously like this).
Alternatively, you can use the run_practical()
function in the Console
pane. For example, run_practical("practical1-1")
will run the first
practical of practical series 1.
If you decide to run a practical like this, you will not be able to use the R console until you close it, so we suggest that you open a separate instance of RStudio to run any code, so one RStudio is dedicated to running practicals and lectures.
To reset a practical if you want to start again, click on the Start Over link (look for the tiny grey text below the left menu), which appears if you are not running this inside the Tutorial pane.
To close a practical if you opened it from the Tutorial pane when you have finished it, click on the red STOP button in the Tutorial pane or close the separate window. Clicking instead on the Home icon will return to the practical list, but you can resume the practical from where you left off by restarting it.
To close a practical if you opened it from the Console pane when you have
finished it, close the webpage in your web browser, then either hit escape
or
click on the red STOP button in the RStudio Console to end the process.
If you are having problems with the practicals running correctly, try
running RPiR:::clean_cached_exercises()
in the Console pane to force the
practicals to be rebuilt.
You can also browse the non-interactive practicals on the GitHub website
(under Practicals (html)
).
To view lecture slides, use the run_lecture()
function in RStudio. For
example, run_lecture("RPiR1-intro")
will show the first lecture slides.
You can also see the lectures on the course website using the lecture
dropdown menus, either as slides (under Lectures (slides)
) or as single
continuous documents for later reference (under Lectures (html)
).
The following core practicals are included in this package:
Practical series 1:
practical1-1
: Exponential growth model; Writing scripts and commenting codepractical1-2
: Exponential growth model; Writing functionspractical1-3
: Exponential growth model; Sourcing codepractical1-4
: Exponential growth model; Generalising and structuring codepractical1-5
: Births and deaths model; Generalising codepractical1-6
: Births and deaths model; Writing reports in RStudioPractical series 2:
practical2-1
: SIS model; Adapting previous codepractical2-2
: SIS model; Changing the timesteppractical2-3
: SIS model; Using while() loopspractical2-4
: SIR model; Adapting previous codePractical series 3:
practical3-1
: Writing an R packagepractical3-2
: Simple stochastic birth-death model; Using stop()practical3-3
: Stochastic birth-death model; Passing functions as argumentspractical3-4
: Stochastic SIS modelpractical3-5
: Stochastic SIR modelpractical3-6
: Comparing mean stochastic and deterministic SIR modelsPractical series 4:
practical4-1
: Creating an R data packagepractical4-2
: Adding some fucntions to a data packagepractical4-3
: Adding a demoProject:
project0
: Setting up the project repoproject1
: Creating species richness and Simpson diversity functionsproject2
: Creating a general diversity functionproject3
: Adding in code to cope with Shannon entropy and Berger-Parkerproject4
: Adjusting the diversity function to handle multiple values of qproject5
: Extending the work to examine properties of subsampled dataAs well as the following additional practicals:
practicalA-1
: Introduction to if statements and comparisonspracticalA-2
: Introduction to functionspracticalA-3
: Naming of thingspracticalA-4
: Introduction to for and while loopspracticalA-5
: Nested functions