University of Melbourne · FACULTY OF DATA SCIENCE

GEOM90007 Chap.11 R, ggplot2 and Reproducible Graphics

- one subject, every graph, every model, every mark
5 Chapters2-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 11 of 13 · GEOM90007

R, ggplot2 and Reproducible Graphics

Define tidy data

R, ggplot2 and Reproducible Graphics connects tidy data, grammar of graphics and reproducible graphic along an information-visualisation pipeline: data type, visual encoding, perception, task fit and evaluation.

The practical aim is to write a ggplot2 specification whose mappings, transformations and labels expose the analytical choices; the display is defensible only when each encoding choice can be traced back to the analytical question and the structure of the data.

Place tidy data at its correct stage: question, data specification, transformation, encoding, perception, tool or evaluation.

For tidy data, record the variables, measurement levels, granularity, missingness and comparison task wherever they apply before choosing or judging a chart.

Use grammar of graphics to make the next transformation, encoding, layout, interaction or evaluation step explicit.

When grammar of graphics involves marks and channels, state which values they represent and check whether scale, ordering, aggregation or filtering changes the apparent pattern.

Use reproducible graphic to test perceptual and task fit.

In R, ggplot2 and Reproducible Graphics, ask whether viewers can make the required comparison accurately, whether uncertainty and exceptions remain visible, and whether colour, position, motion or interaction creates an avoidable accessibility or interpretation cost.

Trace grammar of graphics

For the application — write a ggplot2 specification whose mappings, transformations and labels expose the analytical choices — compare at least one alternative encoding against the same data and task.

Retain the design only if the reproducible graphic evaluation shows that it reveals the intended relationship without introducing a stronger distortion or hiding the evidence needed to challenge it.

Make a compact pipeline audit for tidy data: question or data field; transformation; mark and visual channel where applicable; intended task; evaluation evidence; and likely failure.

Locate grammar of graphics and reproducible graphic at their actual stages so a technically valid implementation is not mistaken for an effective display.

Test a changed grammar of graphics view. Hold the data and question stable, replace the channel most closely tied to grammar of graphics, and predict which comparison becomes easier or harder.

Evaluate the result with reproducible graphic, including uncertainty, accessibility and the possibility that an apparent pattern is produced by scale, binning, projection or interaction state.

Critique R, ggplot2 and Reproducible Graphics in task order: state the question around tidy data, classify the data, describe the role of grammar of graphics, predict the perceptual judgement and report the reproducible graphic evaluation evidence.

Revise the first stage where reproducible graphic shows that the visual no longer supports the task instead of adding decoration to a structurally unsuitable chart.

Test with reproducible graphic

A complete response should make the task visible before the detail: identify what must be decided, define the relevant terms, connect the evidence to grammar of graphics, and use reproducible graphic to test the result.

The final sentence about reproducible graphic should answer the question actually asked rather than merely repeat the topic.

The controlling limit is specific: Reproducible code does not guarantee valid data, sound statistics or accessible communication.

Keep that reproducible graphic limit beside the worked example, because it separates a careful GEOM90007 answer from one that sounds confident but claims more than the task or evidence supports.

For revision, retrieve tidy data, grammar of graphics and reproducible graphic without notes, explain their relationship aloud, then complete a changed version of the application: write a ggplot2 specification whose mappings, transformations and labels expose the analytical choices.

Record the first failed grammar of graphics reasoning move and repair it before attempting another case.

In this chapter

What this chapter covers

  • 01

    tidy data

  • 02

    grammar of graphics

  • 03

    reproducible graphic

  • 04

    Applying tidy data

  • 05

    Limits of grammar of graphics and reproducible graphic

Worked example · free

Worked example: R, ggplot2 and Reproducible Graphics

Q [4 marks]. While trying to write a ggplot2 specification whose mappings, transformations and labels expose the analytical choices, a draft jumps from tidy data directly to reproducible graphic. Restore the missing grammar of graphics link and state the limit on the conclusion. This is AskSia-authored practice, not a University question or marking scheme.
  • 1Mark the starting condition or object represented by tidy data.
  • 1Write the change, rule or mechanism supplied by grammar of graphics as a verb-led link.
  • 1Show how that link reaches reproducible graphic; do not skip an intermediate actor, quantity or stage.
  • 1Answer the task with the completed chain and preserve this limit: Reproducible code does not guarantee valid data, sound statistics or accessible communication.
The completed chain begins with tidy data, states what grammar of graphics changes, and only then reaches reproducible graphic. Each arrow therefore represents a checkable mechanism rather than an association. The chain supports no broader conclusion than this boundary allows: Reproducible code does not guarantee valid data, sound statistics or accessible communication.
Sia tip — Reproducible code does not guarantee valid data, sound statistics or accessible communication.
Glossary

Key terms

tidy data
A tabular structure in which each variable is a column, each observation a row and each observational unit a table. Use this definition when the task is to write a ggplot2 specification whose mappings, transformations and labels expose the analytical choices.
grammar of graphics
A framework constructing a visualisation from data, aesthetic mappings, statistical transformations, geometric marks, scales and coordinates. Use this definition when the task is to write a ggplot2 specification whose mappings, transformations and labels expose the analytical choices.
reproducible graphic
A figure that can be regenerated from recorded data, code, environment and parameters rather than manual editing alone. Use this definition when the task is to write a ggplot2 specification whose mappings, transformations and labels expose the analytical choices.
FAQ

R, ggplot2 and Reproducible Graphics FAQ

What is the main task in R, ggplot2 and Reproducible Graphics?

Write a ggplot2 specification whose mappings, transformations and labels expose the analytical choices.

How do tidy data and grammar of graphics work together?

Use tidy data to establish the object or condition, then use grammar of graphics to explain how it changes the outcome being analysed.

What must a GEOM90007 answer qualify here?

Reproducible code does not guarantee valid data, sound statistics or accessible communication.

How should I revise R, ggplot2 and Reproducible Graphics?

Retrieve tidy data, grammar of graphics and reproducible graphic, apply them to a changed case, and correct the first point where the evidence no longer supports the conclusion.

Study strategy

Assessment move

Reconstruct the relationship among tidy data, grammar of graphics and reproducible graphic; complete the chapter application without notes; then test the result against this limit: Reproducible code does not guarantee valid data, sound statistics or accessible communication.

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

A+Everything unlocked
Unlocks this Bible + all 126 of your University of Melbourne subjects - and 1,000+ Bibles across every Australian university.
Sia - your GEOM90007 tutor, unlimited, worked the way the exam marks it
The full 2-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