SOST10031 Chap.6 Reproducibility and Automation
Reproducibility and Automation
Reproducibility and Automation explains the working habits that let another person rerun your analysis and reach the same results. The chapter starts with the supplied project folder: the project file sets the working directory, the data and images folders keep their places, and paths such as data/ only work while that structure stays intact.
It then separates the jobs of R, RStudio and Quarto, describes what rendering actually does, and treats the rendered page as an output to inspect rather than a file to edit. Packages are installed once per computer and loaded at the start of every session, a distinction that removes a common source of errors.
Automation appears through stopifnot checks, which stay silent when stated conditions hold and halt the run when one fails, and the chapter is careful about what such checks can and cannot prove. The same standard of verification extends to suggestions from the University provided Copilot service: they are inputs to test against your results and the documentation, and your decisions about them are recorded.
What this chapter covers
- 01
Project files and the working directory
- 02
How R, RStudio and Quarto divide the work
- 03
What rendering a Quarto document does
- 04
Installing packages once and loading them each session
- 05
Automated checks with stopifnot
- 06
Run, Source and Source with Echo
- 07
Diagnosing a render that stops
- 08
Checking and recording AI suggestions
Worked example · free
Diagnose a starter project that will not render
- 2Identify the cause: the project was not opened through the .Rproj file, so the working directory is not the project folder and the relative path beginning with data/ does not resolve.
- 1Fix it by closing RStudio, opening the .Rproj file, then opening the .qmd from the Files panel and rendering again.
- 1Confirm success: the render finishes without red error text and the page shows the expected text, table and chart in the order of the source.
Key terms
- Reproducibility
- The property of an analysis that another person can rerun with the same code and data and obtain the same results.
- Working directory
- The folder R treats as its starting point when it looks for files, set by opening the project file.
- Rendering
- The Quarto step that runs a document's code from top to bottom and combines text, results and charts into a finished page.
- Automated check
- A line of code that tests a stated condition and stops the run with an error if the condition is false.
- Source with Echo
- An RStudio option that runs a whole script while printing each instruction and its output in the Console.
Reproducibility and Automation FAQ
Why must I open the .Rproj file instead of the .qmd file?
Opening the project sets the working directory to the project folder, so relative paths such as data/ resolve on any computer. Opening a document directly can leave R looking in a different folder, which produces errors about files that seem to be missing even though they are present.
Should I put install.packages in my Quarto document?
No. A package needs installing only once on a computer, so that command belongs in the Console. The document itself should load packages with library at the top, because loading must happen afresh in every new R session before the functions can be used.
What does a passing stopifnot check prove?
It proves only that the conditions you wrote were true when the code ran, for instance that one row was selected and a calculation matched an expected value. It says nothing about whether the measure suits the question, whether dates align or whether your interpretation is sound.
Assessment move
Build reproducible habits by repeating the same opening ritual until it is automatic: open the project file, open the source document from the Files panel, render, and inspect the page before doing anything else. Keep the supplied folder structure untouched and resist saving copies of data elsewhere.
When something fails, practise reading the entire error message and noting the file, the action and your operating system, then compare names, quotation marks and brackets before asking for help. Run the supplied lecture script line by line with Run, then again with Source with Echo, and notice what each option shows you.
Write two or three stopifnot conditions for any selection or calculation you make, choosing conditions a realistic mistake would break. Keep a short running log of suggestions from Copilot, with what you accepted, what you rejected and why, so the portfolio reflection draws on real decisions. Before any submission, close everything, reopen the project and render from scratch.
Working through Reproducibility and Automation in SOST10031? Sia is AskSia’s AI Computer Science tutor — ask any SOST10031 Reproducibility and Automation question and get a clear, step-by-step explanation grounded in how SOST10031 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.