{targets} introduction

ryan crawford

2026-03-04

designed to avoid the following scenario

  1. Launch the code.
  2. Wait while it runs.
  3. Discover an issue.
  4. Restart from scratch.

from: https://books.ropensci.org/targets/

how so?

  • checks what has been done, compares with what needs to be done, and does what needs to be done.

  • {targets} does this within R (contrast this with other pipelines tools, often built for python or bash (snakemake/ make))

  • in practice, you wind up writing functions that define what you are doing/ have done.

  • as you update the functions/ add to your workflow, targets ensures that everything is up to date

  • that also means that you can change the workflow and only rerun the parts that have changed

useful parts (to me)

  • forces me to write functions

  • can save lots of time (if a model or analysis is complicated)

  • randomization seeds associated with individual targets

  • tarchetypes (related package) for file tracking

  • there are also things i have no experience with (parallel computing) that may be very useful to others

issues i’ve experienced

  • debugging functions can be hard (problem is often (but not always!) mine)
  • sometimes weird things happen in memory (an object isn’t getting updated)–you wind up having to destroy targets/ restart etc.
  • being sure that qmd/ rmd files are updating.
  • won’t save you from yourself (you can totally write a suboptimal pipeline that runs)

useful resources