edwardlavender/patter-demo
R code supporting Lavender et al. (2025). patter: particle algorithms for animal tracking in R and Julia. Methods in Ecology and Evolution. https://doi.org/10.1111/2041-210X.70029
A simple demonstration of the patter package
Edward Lavender*
*This repository is maintained by Edward Lavender
(edward.lavender@eawag.ch).
Introduction
This repository contains methods, written in
R and organised as an
RStudio
Project, for Lavender
et al. (in prep). patter: particle algorithms for animal tracking in
R and Julia. In this project, we simulate animal tracking data and
apply particle filtering and smoothing algorithms to reconstruct
patterns of space use. The code forms a basic worked example of the
patter R package.
Description
Dependencies
The project was built in R (version 4.3.1)
in RStudio and implements local dependency
management using
renv. This
manages the installation of the
dv package (from
GitHub), as well as other packages from the
Comprehensive R Archive Network. The
first time the project is opened,
renv can be used
to regenerate the local project library, as described in renv.lock
(via .Rprofile and renv/activate.R).
Directories
The project follows a standardised structure encouraged by the
dv package. The high-level
structure was generated via dv::use_template_proj(). The contents as
follows:
-
renv/implements local dependency management. -
data/contains data:spatial/contains spatial datasets (sourced from
patter-flapper);data.table/,filter/,smoother/,sim/andud/contain
script outputs;inst/contains RStudio
Project-management
files generated bydv:dependencies.rdsis a list of dependencies;session-info.rdsis a record of information about theR
Session;tree.rdsis a record of the project directory tree (as
generated bydv::use_template_tree()indev/01-dev.R, see
below);
-
R/contains scripts for data preparation, simulation and
analysis:preparation.Rprepares spatial dataset(s);workflow.Rsimulates and analyses animal tracking datasets;figs.Rproduces manuscript figures;
-
src/contains helper (R) functions. -
Julia/contains aJuliaproject.- This is set up by
patter;
- This is set up by
-
dev/contains project-management scripts.01-dev.Rand02-clone.Rare standard
dvscripts:01-dev.Rrecords project set up and development;02-clone.Ris used to clone the project (see ‘Instructions’);
-
fig/contains figures. -
doc/contains supporting documents.
Note that the data/ (except data/inst/), fig/ and doc
directories are not provided in the online version of this repository.
Instructions
Follow the steps described below to clone the project and reproduce the
workflow.
-
Clone the project via GitHub. Follow the instructions in
dev/02-clone.Rto install packages and directories: -
Source (raw) data via the links provided (or the authors).
-
Implement workflow via
Rscripts.
Citation
Lavender et al. (2025). patter: particle algorithms for animal
tracking in R and Julia. Methods in Ecology and Evolution, 00, 1–8.
https://doi.org/10.1111/2041-210X.70029
Code of conduct
Please note that this project is released with a Contributor Code of
Conduct.
By contributing to this project, you agree to abide by its terms.