Publications by Bluecology blog

Fast functions with pipes

28.12.2020

Fast functions with pipes Pipes are becoming popular R syntax, because they help make code more readable and can speed up coding. You can even use pipes to create functions. This is handy if you want to repeat a piped process for several different datasets. Trivial example Let’s start with a trivial example. You can access pipes through the tid...

2618 sym R (1182 sym/6 pcs) 4 img

How to solve common problems with GAMs

26.03.2021

How to solve common problems with GAMs Here I’ll provide solutions to some common problems I run into when fitting GAMs with mgcv and ways to solve them. The four problems are: Categorical variables should be input to gam() as factors Adjust the degrees of freedom parameter to avoid an error involving the maximum degrees of freedom Use the R...

5877 sym R (1335 sym/12 pcs) 16 img

When interpolation doesn’t work with GAMs

26.03.2021

When interpolation doesn’t work with GAMs GAMs shouldn’t be used for extrapolation, and they can give strange results for interpolation too. Here I’ll explain why and we’ll look at a solution that involves changing the order a smoother’s penalty. Gaps in an x-covariate, such as gaps in a time-series, can be a problem to deal with if you...

3794 sym 4 img

A comparison of terra and raster packages

27.05.2021

A comparison of terra and raster packages The terra package looks designed to replace an old favourite raster. It is made by a similar team. The terra documentation states “can do more, is simpler to use, and it is faster.” So should you make the switch to terra? I’ll answer that here. TLDR: terra is simpler and faster than raster and will ...

3774 sym R (1039 sym/5 pcs) 6 img

A comparison of terra and stars packages

31.05.2021

Comparison of terra and stars packages The other day I wrote a comparison of raster and terra packages. The other newish raster package on the block is stars. So I go through the same code here. If you are starting out with stars, read their manual first. But first some key differences. stars is set-up to work with spatio-temporal arrays (terra a...

2761 sym R (1430 sym/5 pcs) 6 img

Current approaches to Species Distribution Modelling in R

21.09.2021

Current approaches to Species Distribution Modelling in R My course notes for “Current approaches to Species Distribution Modelling in R “ for World Fisheries Congress 2021 are now free online. The course covers tidyverse and sf workflows for models, a beginners intro to modelling options and how to make spatial predictions. There’s also bo...

826 sym

Running R code for all combinations of some parameters with lapply karate

30.09.2021

Running R code for all combinations of some parameters with lapply karate Sometimes we want to run the same bit of code many times for different parameters. Then if we have multiple parameters, we may want to run the code for all combinations of those parameters. I use what I call ‘lapply karate’ to perform this task. Applications include in ...

4913 sym R (3170 sym/12 pcs) 10 img

Rules of thumb for the design of ecological experiments

06.12.2021

Rules of thumb for the design of ecological experiments Are you planning an experiment in the lab or field, or an observational study? Its a good idea to talk to a statistician before you start. Students often ask me for help with statistics after they’ve collected their data. However, it’s common they need help with statistics because of iss...

11080 sym R (1272 sym/2 pcs) 4 img