Module 14 · Project 7 · Due the date on Canvas · Reproducibility & AI Audit · adaptive competency DV22
Repair the reproducibility failures
Module 14 · Step 2 of 9 · Guided10–12 min
Why this lab Choose reproducibility repairs, then implement and test them in a real clean run.
This step examines four failures: uncontrolled random state, a path that exists on one machine, a hidden dependence on execution order and an unrecorded package version. Each repair must make the analysis portable, not merely make it run on one machine.
A script that ran once without errors on your machine is not yet reproducible. It is reproducible when a clean run, in a fresh session on another machine, regenerates the same result from versioned inputs, the code and a recorded environment (Peng, 2011). Four practices establish that condition (Sandve et al., 2013):
- Random state. Uncontrolled random state can change a result between runs. To reproduce a stochastic sequence under the same generator, code, inputs and execution order, call
set.seed(2026), or any fixed number, immediately before the random sampling, and record that seed with the code. Record the R version and RNG kind too; a seed alone does not freeze software, data or numerical behavior. Repeated estimates can also coincide by chance. Choosing a repair here does not run or modify the example script. - File paths. A path such as
C:/exists only on one machine. Use a project-relative path such asUsers/ analyst/ Desktop/ final.csv data/that points to a versioned snapshot of the data stored with the project.scores-2026-09.csv - Execution order. Run the script top to bottom in a clean session. It must create every object it uses before the line that needs it; an object left over from an earlier console session will not exist for anyone else.
- Package environment. Packages change between versions and can change your output. Record the package versions, for example with
sessionInfo()or a lockfile, and restore that environment before regenerating; dependencies should be stated explicitly rather than assumed (Wilson et al., 2017).
Reproducibility debugger loading…