How to use {targets} for effective workflows in R

Joel Nitta

Carpentry@UiO

2023/06/08



drawing

https://www.joelnitta.com

Introductions: instructor

@joelnitta@fosstodon.org

https://joelnitta.com

  • Associate Professor @ Chiba University

  • Research interests: Ecology and evolution of ferns

  • Hobbies: Running (after my 7YO!)

Photo: J-Y Meyer

drawing

Introductions, cont’d

  • Name

  • Affiliation

  • What do you want to do with {targets} and/or R?

Outline of today’s workshop

  • Introduction to {targets}

  • Live coding

  • Lunch break

  • More live coding

  • Bring Your Own Data (BYOD)

Setup

Collaborative notes

Code of Conduct

About The Carpentries

Why {targets}?

To make your code more reproducible

What is reproducibility?

The ability for others (or your future self) to re-run your code and get the same results

  • Not “yes” or “no”
  • Reproducibility = mindset
  • Many aspects
    • Computing environment
    • Data availability
    • Code automation

Workflows in R

Hadley Wickham's data analysis workflow chart

  • Which steps need to be run in what order?

Workflows in R

Hadley Wickham's data analysis workflow chart with icon showing part of it changed

  • If one part of a workflow changes, how does it affect other parts?

  • How much of it do we need to re-run?

What is {targets}?

  • Automates workflow

  • Only runs necessary steps

  • Can run workflow steps in parallel (speeds up analysis)

  • Provides proof that results are derived from code

targets logo

Resources

Live Coding

All lesson materials at https://joelnitta.github.io/targets-workshop/