Tidy Ecology
  • Start here
  • Course
  • Book
  • Topics
    • R for ecologists
    • Species diversity
    • Ordination
    • Occupancy modelling
    • Capture-recapture
    • Movement ecology
    • Population models
    • Species coexistence
    • Ecological time series
    • Causal inference
    • Evolutionary game theory
    • Quantitative genetics
    • Population genetics
    • Landscape connectivity
    • Conservation decisions
    • Bayesian computation
    • Reproducible workflows
    • Data provenance checks
  • Blog
  • About
  • Contact

N 46.77° · E 23.59° · R + QGIS

R & QGIS tutorials
for ecologists.

Field data, cleanly analysed: reproducible R & QGIS workflows for ecologists who'd rather spend their time on the ecology than on fighting their tools.

Learn step by step: the course → Find a method by task → Search the tutorials ⌕ Latest tutorials ↓

// Latest

Records on grid lines and floating point in R
R
GIS
terra
sf
occurrence data
data cleaning
ecology tutorial

One-decimal records sit on the lines of a 0.1 degree atlas grid. Count how floor(), terra and sf place them, and assign cells in R with integer arithmetic.

Sep 28, 2026
When integrate() in R returns zero and says OK
R
numerical methods
measurement error
likelihood
reproducibility
ecology tutorial

R’s integrate() returns zero and says OK for a density far from the origin. How it breaks a measurement-error likelihood, and which change of variable fixes it.

Sep 28, 2026
Parameter scale decides what optim() finds
R
numerical methods
likelihood
population dynamics
reproducibility
ecology tutorial

One Ricker fit, two spellings: optim BFGS in (r, K) stops far below the exact carrying capacity, and raising maxit makes it report success. Why, and the fix.

Sep 28, 2026
The delta method: standard errors for derived values
R
statistics
GLM
logistic regression
uncertainty
simulation
ecology tutorial

The delta method in R: a standard error for a species’ thermal optimum from glm() coefficients, and what dropping their covariance does to the interval.

Sep 28, 2026
Maximum likelihood by hand with optim() in R
R
maximum likelihood
GLM
nonlinear regression
count data
statistics
ecology tutorial

Write a negative log-likelihood in R, minimise it with optim(), match glm() to four decimals, avoid the product that underflows, then fit a curve glm() cannot.

Sep 28, 2026
What a p-value tells you, and what it does not
R
statistics
hypothesis testing
simulation
ecology tutorial

What a p-value means, checked by simulating the null in R, and why p = 0.03 in a grazing experiment is no promise that an exact repeat will be significant.

Sep 28, 2026
Simulating correlated variables in R
R
simulation
statistics
count data
ecology tutorial

Simulate correlated variables in R by hand, with chol() and with mvrnorm(), and why a correlation set on the log scale is not the correlation of the counts.

Sep 28, 2026
Probability distributions in R: d, p, q and r
R
statistics
count data
simulation
ecology tutorial

The d, p, q and r functions in R on ecological counts and lengths, why 1 - ppois(k) is not the chance of at least k, and checking parameters by simulation.

Sep 27, 2026
Repeating an analysis for every site in R
R
data wrangling
dplyr
ecology tutorial

Fit the same model at every site in R with split, lapply and purrr, and catch the silent faults: sapply changing shape, empty loops and failed sites dropped.

Sep 27, 2026
ggplot2 facets: fixed or free axis scales
R
ggplot2
data visualisation
monitoring
ecology tutorial

Fixed or free_y scales in ggplot2 facet_wrap(): what each does to trend lines, measured off the built plot on simulated wetland counts, and an index as the fix.

Sep 27, 2026
Missing values in summaries: na.rm and false zeros
R
missing data
monitoring
count data
GLM
ecology tutorial

What sum(), mean() and max() do with NA in R, why sum(na.rm = TRUE) turns unwalked months into a false decline, and two fixes, measured on simulated transects.

Sep 27, 2026
Recoding field data in R: ifelse, if_else, case_when
R
dplyr
data wrangling
data cleaning
missing data
ecology tutorial

Turning tree diameters into size classes in R: why case_when order matters, where the missing values end up, and what ifelse does to dates and factors.

Sep 27, 2026
Factor levels in R: reference groups and empty sites
R
dplyr
data wrangling
data cleaning
regression
ecology tutorial

Factor levels in R decide which group a model compares against and which sites vanish from a count. Set them from the design, keep empty sites, catch stray NAs.

Sep 27, 2026
Reading Excel field sheets into R
R
data import
readxl
missing data
data cleaning
ecology tutorial

Read an Excel field sheet into R with readxl: why a count typed as text after row 1000 becomes NA, and why a date column with text arrives as serial numbers.

Sep 27, 2026
Moran’s I on residuals: moran.test or lm.morantest
R
spdep
spatial
autocorrelation
regression
model checking
ecology tutorial

Residuals of a model with smooth predictors have a lower null mean than raw data. Why moran.test and moran.mc lose size and power there, and lm.morantest in R.

Sep 26, 2026
Spatial cross-validation when the target is a map
R
cross-validation
spatial statistics
kriging
model validation
ecology tutorial

Block or random cross-validation for a kriged map? Simulated in R: block folds overstate a random sample’s map error, random folds understate a clustered one.

Sep 26, 2026
Geographical detector: the interaction rule
R
spatial
GIS
interactions
variance partitioning
simulation
ecology tutorial

The geographical detector calls independent, additive drivers a nonlinear enhancement in over half of datasets. Why, what q is, and where shift tests fail.

Sep 26, 2026
Snapped coordinates and a clustering verdict
R
point patterns
spatial ecology
occurrence data
data cleaning
ecology tutorial

Records stored at grid centroids make a random pattern look clustered, and one record per cell makes it look regular. Measuring both in R with Clark-Evans.

Sep 26, 2026
Reprojecting a raster in QGIS and R: opposite defaults
R
QGIS
terra
GIS
spatial
raster data
ecology tutorial

QGIS Warp copies the nearest cell and terra project() interpolates unless told otherwise. What each does to a land-cover map and a DEM, and how to match them.

Sep 26, 2026
Natural breaks in QGIS and R: Jenks on large layers
R
QGIS
GIS
spatial
classInt
cartography
ecology tutorial

QGIS Natural Breaks against R classInt on a species richness grid: which modes match exactly, and why Jenks above 30009 cells classifies phantom zeros.

Sep 26, 2026
QGIS NULL and R NA: what survives the trip
R
QGIS
sf
GeoPackage
missing data
data management
ecology tutorial

QGIS NULL and R NA agree on comparisons and filters, but not on bare [ indexing, aggregates or pasted text, and a CSV export merges NULL with empty text.

Sep 26, 2026
Area in QGIS and R: which call matches which
R
QGIS
sf
GIS
spatial
ecology tutorial

QGIS $area, area() and sf st_area() give different areas for one habitat patch. Each has an exact partner in the other tool, and headless QGIS hides a trap.

Sep 25, 2026
Attrition in a field experiment: when pots die first
R
experimental design
causal inference
missing data
simulation
ecology tutorial

When a treatment changes which pots survive to harvest, the survivor contrast is not the effect. Lee bounds, Imbens-Manski intervals and the survival gap in R.

Sep 25, 2026
Randomising treatments to plots in R
R
experimental design
power analysis
simulation
ecology tutorial

Randomise treatments to plots in R with sample(): two sample() traps, what pairing plots on a gradient buys, and how analysing the pairs as two groups loses it.

Sep 25, 2026
No matching items

    All tutorials, by date, title or topic →

    Newsletter

    Get updates by email

    An occasional email when tutorials are added or substantially corrected. No spam; unsubscribe anytime.

    By subscribing you agree to receive these emails and confirm your address once. See the privacy policy.

    ESC

    Type to search the tutorials

      © 2026 Tidy Ecology

      • About

      • Disclaimer

      • Privacy

      • Terms

      • DMCA