The Tidy Ecology course
The start-here page is a map of the whole site, grouped by subject, and it assumes you already know which subject you want. This page assumes the opposite. It is one route, numbered, from a messy field sheet to a result you would be willing to defend, and it says what each step is for and why it comes where it does.
Forty-four tutorials, in order. That is a term of evening reading rather than a weekend, and skipping ahead is fine as long as you come back: the later parts lean on the earlier ones, and the two places where that dependency really bites are called out below. Everything runs in base R with a small number of well established packages, on data small enough to sit in memory.
Part one: get the data into R
Most of the time an ecologist loses to R is lost here, before any method is chosen. These six steps are the ones that stop a spreadsheet from arriving in R as something subtly other than what it says on the field card.
- Setting up R and RStudio for ecology puts a project in place instead of a working directory, and shows the hidden-state bug that changes an answer with nothing on screen to say so.
- Reading field data into R covers the arguments that decide whether an empty cell becomes a zero, a missing value, or a character column.
- Wide and long: reshaping species data moves between the species matrix every community method wants and the one-row-per-record shape every database gives you.
- Cleaning species names before you count builds a lookup table, and makes the case against fuzzy matching by showing what it merges.
- Dates and times in ecological data is short and saves entire field seasons: the transposed day and month that never warns, and where the silent missing value comes from.
- Joining ecological tables without losing zeros is the step that decides whether your absences survive, which decides most of what follows.
Part two: a first result, and what it is worth
Before any modelling, produce something and put an interval on it. A number without an interval is not yet a result.
- Your first ggplot: data, aes and geom covers the three pieces of a plot and the mapping-versus-setting mistake everyone makes once.
- Summarising ecological data by group groups and summarises, and explains why the mean of proportions is not the pooled proportion.
- From a field sheet to your first analysis runs parts one and two end to end on a messy sheet.
- Standard errors and confidence intervals is what a standard error actually measures, and why coverage is the property that matters.
Part three: describe the community
Community data have their own summaries, and the choice between them is a choice about what you are claiming, not a matter of taste.
- Diversity indices in R gets richness, Shannon and Simpson out of a site-by-species matrix.
- When not to use Shannon is the reason step eleven is not the end of the story, and introduces Hill numbers.
- Rarefaction and accumulation curves compares richness across uneven effort, which is the usual situation.
- Estimating species richness beyond your sample goes after the species you did not see, and is honest about these estimators being lower bounds.
- Beta diversity partitioning splits the difference between two sites into turnover and nestedness, which answer different ecological questions.
Part four: find the structure
Ordination is where community data become a picture. The picture is only as good as the distance underneath it, which is why the first step here is the distance and not the method.
- Choosing a dissimilarity index is the decision every ordination and PERMANOVA inherits from you.
- NMDS ordination is the workhorse for composition, with stress read properly.
- PCA on environmental data is the abiotic counterpart, and the standardisation question that goes with it.
- envfit and PERMANOVA tests whether the groups on the picture differ, rather than asserting it from the picture.
- Common PERMANOVA mistakes is the one to read before you report a result, not after: dispersion against location, permutation structure, and unbalanced designs.
Part five: model a response
This is the first place where skipping ahead hurts. Everything after this part assumes you can fit a GLM, read its residuals and predict from it on the scale you care about.
- Classical tests as linear models collapses the t-test and ANOVA into the one framework that the rest of the course extends.
- Logistic regression for presence-absence is the binomial case, with the logit link made concrete.
- GLMs for count data explains why counts are not logged and what to fit instead.
- Offsets for rates and densities is how effort enters a count model, and it is not a covariate.
- GLM residual diagnostics covers why the familiar residual plot misleads on a GLM, and what to look at in its place.
- Predicting on the response scale builds the interval on the link scale first, which is the order that keeps it inside the possible range.
- Collinearity and VIF is the diagnostic for predictors that carry the same information twice.
Part six: the structure regression ignores
Field data are grouped, nested and repeated, and a model that pretends otherwise reports intervals that are too narrow rather than too wide.
- Pseudoreplication in ecology is the concept, with the error rate it costs measured.
- GLMMs for nested counts is the fix, with random intercepts.
- Random slopes in mixed models covers when a shared slope understates the uncertainty on the effect you are reporting.
- GAM species response curves relaxes the straight line where the ecology says the response is humped.
- Model selection and AIC is what AIC measures, and what it does not.
Part seven: put it on a map
Enough spatial work to handle occurrence records and raster layers, and to notice when nearby sites are quietly repeating each other.
- Cleaning GBIF and iNaturalist records comes before any mapping, because bad coordinates map perfectly well.
- Richness mapping with sf is vector data, projections and a map that means something.
- Raster basics with terra covers raster structure and map algebra.
- Spatial autocorrelation and Moran’s I tests whether your residuals are independent in space, which parts five and six assumed without checking.
Part eight: make the result hold up
The second place where skipping hurts. A result that nobody can reproduce, and whose data nobody compared with the design, is not finished, however good the model is.
- Bootstrap confidence intervals gives you an interval where no formula exists, which by this point is most of what you will want.
- Power analysis by simulation answers the design question with the model you actually intend to fit.
- Checking your data against the design is the step almost every course leaves out: five checks comparing the returned data with the frame, the protocol, the recording grid, the allocation and the code list.
- A reproducible statistical workflow settles where the seed goes, how paths are written, and what a clean-session render proves.
- Testing your analysis code puts a test runner in a screenful of base R and scores it against deliberately planted bugs.
- Checking an analysis script asks the three questions a reviewer asks: clean session, same answer twice, and numbers that match what the code computed.
- Effect plots that show the data turns a fitted model into the figure a reader can argue with.
- Publication-quality ggplot figures is physical size, resolution and export, which is where a good figure is usually lost.
After the course
Forty-four tutorials cover the spine of an analysis and none of the branches. Where you go next depends on your data rather than on your level.
- Start here is the full map, grouped by subject, and every tutorial on the site is on it.
- Data provenance checks in R extends step thirty-nine into a subject of its own, for anyone working with monitoring series, long species lists or records collected by somebody else.
- Species diversity in R and Ordination in R go deeper into parts three and four.
- Occupancy modelling in R and Capture-recapture in R are the route for anyone whose real problem is that detection is imperfect, which parts five and six assumed away.
- Reproducible workflows in R is part eight taken seriously, including dependency pinning, pipelines and version control.