Build a reproducible R analysis with targets

8 steps · about 4 h 25 min · Intermediate

  1. Build a first targets pipeline (guide, The targets R package user manual, 40 min)

    A small working graph introduces targets, commands and dependency-aware execution together.

  2. Move analysis steps into functions (guide, The targets R package user manual, 35 min)

    Pure focused functions make dependencies visible and individual steps testable.

  3. Declare package dependencies (guide, The targets R package user manual, 25 min)

    Workers must load the same packages explicitly rather than inherit an interactive session.

  4. Branch over changing groups of work (guide, The targets R package user manual, 40 min)

    Dynamic branching scales repeated analysis while preserving each branch in the dependency graph.

  5. Track files as pipeline inputs and outputs (guide, The targets R package user manual, 30 min)

    File targets invalidate downstream work when external data or generated artifacts change.

  6. Diagnose a failed target (guide, The targets R package user manual, 30 min)

    Saved workspaces and metadata make a failure reproducible outside the full run.

  7. Record the package environment with renv (guide, renv documentation, 35 min)

    A lockfile preserves the package versions that gave the pipeline its behaviour.

  8. Render the final report predictably (guide, Quarto documentation, 30 min)

    Explicit execution options keep reporting separate from hidden notebook state.