Monash University · FACULTY OF COMPUTER SCIENCE

ETF5922 Chap.5 Data Wrangling for Visualisation

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

Data Wrangling for Visualisation

Rows carry analytical meaning

Select changes columns, filter changes the retained population, and mutate creates variables. Grouping followed by summarise changes the unit represented by one output row.

Summaries change the grain

Pivoting changes layout between wide and long forms without changing the substantive measurements.

Joins can discard unmatched keys or multiply rows when the matching key is not unique.

Join keys before charts

A left join multiplies rows when a key on the right has more than one match.

Checking key uniqueness before plotting prevents duplicated matches from inflating totals or changing the apparent distribution.

Join keys before charts in context

Wrangling verbs alter either columns, rows or analytical grain, and those effects should be predicted before execution.

Selection retains variables, filtering retains qualifying observations, mutation derives values, arrangement changes order, grouping prepares partitions and summarising compresses them. Reshaping reorganises variable names and values, while joining introduces matches from another key space. Each operation has an expected row-count signature. Recording that signature, missing counts and important totals creates an audit trail.

When the chart later changes, the analyst can locate the responsible transformation rather than treating visual inspection as proof that the table remained valid.

In this chapter

What this chapter covers

  • 01

    Select changes columns, filter changes the retained population, and mutate creates variables.

  • 02

    Grouping followed by summarise changes the unit represented by one output row.

  • 03

    Pivoting changes layout between wide and long forms without changing the substantive measurements.

  • 04

    Joins can discard unmatched keys or multiply rows when the matching key is not unique.

  • 05

    Use select and filter to frame the reader's task

  • 06

    Check arrange against mutate before styling

  • 07

    Explain how group changes the visible comparison

  • 08

    Audit summarise without removing necessary context

Worked example · free

Preserve row meaning through a summary

Q [8 marks]. This AskSia-authored scenario carries an illustrative eight-point split that is separate from University grading. This AskSia-authored scenario carries an illustrative eight-point split that is separate from University grading. This AskSia-authored scenario carries an illustrative eight-point split that is separate from University grading. AskSia-authored practice; the point allocation is a study aid, not a University marking scheme. Orders record sales of 40, 60, 80 and NA for regions A, A, B and B.
  • 2Group by region only after confirming that one row is one order.
  • 2Summarise observed sales and count non-missing rows in the same table.
  • 2Carry the missing count into the annotation instead of presenting the smaller group as complete.
  • 2Check that no join duplicated a region before the plot is built.
Region A has observed sales of 100 from two rows. Region B has observed sales of 80 from one row and one missing value, so completeness is 50%. Annotate Region B as one observed order plus one missing order. Any join must preserve those source rows before the 100 versus 80 comparison is allowed onto a chart. Annotate Region B as one observed order plus one missing order. Any join must preserve those source rows before the 100 versus 80 comparison is allowed onto a chart. Annotate Region B as one observed order plus one missing order. Any join must preserve those source rows before the 100 versus 80 comparison is allowed onto a chart.
Sia tip — Count rows and inspect duplicate keys immediately before and after every join.
Glossary

Key terms

Observation grain
The real-world entity represented by one row at a particular stage of a workflow.
Grouping key
One or more variables that partition rows before a summary calculation.
Long format
A structure with identifier columns plus a variable-name column and a corresponding value column.
Join cardinality
The one-to-one, one-to-many or many-to-many match pattern between two key sets.
FAQ

Data Wrangling for Visualisation FAQ

Why can a left join increase the row count?

A left join multiplies rows when a key on the right has more than one match. Checking key uniqueness before plotting prevents duplicated matches from inflating totals or changing the apparent distribution.

What should be checked before a join?

State the key on each table, test uniqueness, predict the cardinality and record the expected row count. After joining, inspect unmatched and multiplied rows and reconcile important totals. These checks stop duplicate keys from creating a convincing but inflated visual summary.

Why preserve missing counts after summarising?

Grouping compresses many source rows into one result, so missingness can disappear precisely when the chart becomes easiest to read. Carrying observed and missing counts forward lets the viewer compare both magnitude and evidence support, especially when groups have different completeness.

How can row-count checks localise a wrangling error?

Record the expected effect after each verb: select and mutate preserve rows, filter removes declared rows, summarise reduces groups and joins follow key cardinality. The first unexpected change identifies the relevant operation. This is faster and more reliable than repairing the final plot while leaving duplicated or missing records in its data.

Study strategy

Exam move

Start with a table whose grain you can state in six words. Filter, mutate, group, summarise and reshape it while writing the row count after every operation. Join a second table only after testing key uniqueness. When the final plot changes, trace the difference backward to the exact transformation rather than adjusting the chart until it looks plausible.

Working through Data Wrangling for Visualisation in ETF5922? Sia is AskSia’s AI Computer Science tutor — ask any ETF5922 Data Wrangling for Visualisation 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