The University of Manchester · FACULTY OF COMPUTER SCIENCE

SOST10031 Chap.6 Reproducibility and Automation

- one subject, every graph, every model, every mark
8 Chapters4-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 6 of 10 · SOST10031

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.

In this chapter

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

Q [4 marks]. A student opens RStudio directly, finds the starter .qmd through the file browser and selects Render. The render stops with a message that the teaching CSV cannot be found, although the file is still inside the data folder. Explain the likely cause, the fix, and how to confirm the render succeeded. AskSia chose the mark allocation for this troubleshooting task, which is not drawn from any official module document.
Boxes show the files inside the supplied starter folder and the orange arrow shows Render turning the .qmd source into a finished .html page, which you read butBoxes show the files inside the supplied starter folder and the orange arrow shows Render turning the .qmd source into a finished .html page, which you read but never edit by hand. week1-starter/ SOST10031.Rproj Starter .qmd source data/ folder images/ folder Render finished .html page read, never edit
Boxes show the files inside the supplied starter folder and the orange arrow shows Render turning the .qmd source into a finished .html page, which you read but never edit by hand.
  • 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.
The working directory was wrong because the project file was not opened first, so the data/ path could not be found. Reopening through the .Rproj file and rendering again fixes it, and success is confirmed by a complete page with no error text in the render panel.
Sia tip — Every working session starts with a double click on the .Rproj file; never begin by opening RStudio and hunting for files.
Glossary

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.
FAQ

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.

Study strategy

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.

A+Everything unlocked
Unlocks this Bible + all 41 of your subjects at The University of Manchester, plus 1,000+ more Bibles across the AskSia library.
Sia - your SOST10031 tutor, unlimited, worked the way the exam marks it
The full 4-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works