Monash University · FACULTY OF COMPUTER SCIENCE

ETF5922 Chap.3 R Foundations and Reproducible Projects

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

R Foundations and Reproducible Projects

Objects need declared origins

Atomic vectors store one basic type, and logical expressions can select or modify their elements. R uses NA for unavailable values, so summaries require an explicit missing-value policy.

Projects replace fragile paths

Factors encode categorical levels, while ordered factors permit ordinal comparisons.

Projects, relative paths and clean-session execution make an R analysis reproducible on another computer.

The clean-session test

A script that works only after earlier console actions depends on objects or packages it never creates.

Restarting R exposes that hidden dependency and shows exactly what the reproducible workflow must declare.

The clean-session test in context

R distinguishes object types, missing values and factor levels in ways that directly affect visual output. Character categories may sort differently after conversion to factors, numeric operations may propagate NA, and a reused object can hide an omitted transformation.

Project discipline makes these dependencies visible. Scripts should create objects from declared inputs, use stable relative locations and record package calls. A clean-session rerun is stronger than checking whether the final picture resembles an earlier one because it tests the entire chain. The resulting narrative should report both the computed value and the availability condition that shaped it.

In this chapter

What this chapter covers

  • 01

    Atomic vectors store one basic type, and logical expressions can select or modify their elements.

  • 02

    R uses NA for unavailable values, so summaries require an explicit missing-value policy.

  • 03

    Factors encode categorical levels, while ordered factors permit ordinal comparisons.

  • 04

    Projects, relative paths and clean-session execution make an R analysis reproducible on another computer.

  • 05

    Use vector and numeric to frame the reader's task

  • 06

    Check character against logical before styling

  • 07

    Explain how factor changes the visible comparison

  • 08

    Audit level without removing necessary context

Worked example · free

Rebuild a summary from a clean session

Q [8 marks]. The following eight-point exercise is an AskSia study device rather than a University marking schedule. The following eight-point exercise is an AskSia study device rather than a University marking schedule. The following eight-point exercise is an AskSia study device rather than a University marking schedule. AskSia-authored practice; the point allocation is a study aid, not a University marking scheme. A numeric vector contains 12, 15, NA, 18 and 20, and the analyst must report both centre and completeness.
  • 1Count available observations and mark the unavailable entry as NA.
  • 2Add only the observed values, then divide by the observed count.
  • 2Report missingness separately from the mean so completeness is visible.
  • 1Run the code from a clean project to confirm no interactive object supplies the result.
  • 2Write the numeric conclusion with its missing-value condition.
The observed sum is 65 across four values, so the mean is 16.25. One of five entries is absent, producing 20% missingness. Report a mean of 16.25 from four observed entries and 20% missingness, with the clean-session rerun establishing that neither value depends on an undeclared object. Report a mean of 16.25 from four observed entries and 20% missingness, with the clean-session rerun establishing that neither value depends on an undeclared object. Report a mean of 16.25 from four observed entries and 20% missingness, with the clean-session rerun establishing that neither value depends on an undeclared object.
Sia tip — Restart R and knit from the top; any object that disappears was never created reproducibly.
Glossary

Key terms

Atomic vector
A one-dimensional collection whose elements share a common underlying type in R.
Missing value
An explicitly unavailable observation represented by NA, not the number zero or an empty string.
Factor level
A categorical variable whose permitted categories and ordering influence summaries and plots.
Project root
The directory anchor that keeps scripts, data and outputs addressable without machine-specific paths.
FAQ

R Foundations and Reproducible Projects FAQ

Why can a clean-session failure reveal hidden state?

A script that works only after earlier console actions depends on objects or packages it never creates. Restarting R exposes that hidden dependency and shows exactly what the reproducible workflow must declare.

What must a reproducible R project declare?

It should identify inputs, package dependencies, object creation order, missing-value treatment and project-relative locations for data and outputs. Running from a clean session is the practical test. If manual console work is required, the project has not yet captured the complete analytical state.

Why report completeness beside a mean?

A mean alone cannot reveal how many expected observations contributed. Reporting four observed values out of five distinguishes an estimate based on available data from a complete record and prevents NA from being silently reinterpreted as zero or ignored without explanation.

What evidence shows that a project is portable?

A second clean environment can open the project, restore dependencies, locate declared inputs and reproduce outputs without editing personal paths. Recording package requirements and keeping derived files separate from inputs make failures interpretable. Portability is demonstrated by reconstruction, not by copying a workspace image that contains hidden objects.

Study strategy

Exam move

Create a small project containing a script, a data file and one output. Include a factor and an NA value, restart R, and run the script without touching the console first. Record every failure as a missing dependency, path or object-creation step. Repeat until a second clean session produces the same summary and plot from the project alone.

Working through R Foundations and Reproducible Projects in ETF5922? Sia is AskSia’s AI Computer Science tutor — ask any ETF5922 R Foundations and Reproducible Projects question and get a clear, step-by-step explanation grounded in how ETF5922 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 101 of your Monash University subjects - and 1,000+ Bibles across every Australian university.
Sia - your ETF5922 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
ETF5922 · Data visualisation and communication - independent study guide on the AskSia Library. More Monash University subjects · Microeconomics across all universities