The University of Melbourne · FACULTY OF STATISTICS

CMCE10002 Chap.4 Visualising Business Data with ggplot2

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

Visualising Business Data with ggplot2

A plot is built in four parts

Week 3 opens with a business challenge, not a chart. Working on retail scanner data for beer, of the kind Australian retailers hold, the class asks what happens to volumes when prices move and whether the imported brands behave differently from the domestic ones. The stated goal is a static data dashboard.

The plot itself is then assembled from four parts: the data, the mapping of columns to visual properties, the geometry that draws, and the labels and scales that make it readable.

The blank canvas is the correct first result

Naming the data alone produces a plot area and nothing else.

That blank frame confirms the first part worked, and it is also a debugging tool: if the canvas appears but the points do not, the fault lies in the mapping or the geometry rather than in the data.

Choosing a geometry is reasoning, not recall

A count over categories is a bar chart. The distribution of one numeric column is a histogram. Two numeric columns are points.

An average is not something a plotting layer computes for you, so it has to be summarised first.

Polish is part of the analysis

The lecture treats labels, scales, themes and colour schemes as things that matter for conveying information rather than as decoration. In a chart aimed at a manager an unlabelled axis is a missing fact, because the reader cannot tell whether the scale is dollars, units or an index.

Treat the final step as the point at which a chart stops being your own working note and becomes evidence somebody else will act on.

In this chapter

What this chapter covers

  • 01

    The business question the week 3 demonstration is built around

  • 02

    Data, mapping, geometry and polish as four separable parts

  • 03

    Why naming the data alone renders an empty plot area

  • 04

    Mapping a column to colour, against setting a colour as a constant

  • 05

    Matching a geometry to the question rather than to the data type

Worked example · free

From a question to a geometry, twice

Q [4 marks]. AskSia assigns four practice points to this independent exercise; they are not a University marking scheme. Choose and justify a geometry for two questions about a delivery log: how the day's deliveries are spread across the five service tiers, and whether delivery times have drifted week by week.
  • 1Identify the quantity the first question is really asking for.
  • 1Choose the geometry and say what supplies the height of each mark.
  • 1Identify what must happen before the second question can be drawn at all.
  • 1Name the trap that sits between the two.
The first question tallies rows inside a small set of labelled categories, so it is drawn as bars with the service tier along the horizontal axis; nothing is assigned to the vertical axis, because producing the tally is the geometry's own job. The second question asks for a mean, which no drawing layer computes, so the table has to be collapsed to one row per week carrying that mean before week and mean are sent to the two axes. The trap between them is that the weekly summary also carries a delivery tally, and drawing the tally instead of the mean produces a picture that looks sensible and answers a question nobody asked.
Sia tip — Read the mapping back against the question before accepting a chart. A plot that renders is not a plot that answers.
Glossary

Key terms

Aesthetic mapping
The instruction deciding which column becomes an axis, and which one drives colour or fill.
Geometry layer
The layer that actually draws the data, as points, bars, lines or a boxplot.
Static dashboard
A fixed set of charts assembled to answer one business question rather than to be explored interactively.
Scanner data
Transaction-level retail records of prices and quantities sold, collected at the point of sale.
FAQ

Visualising Business Data with ggplot2 FAQ

Why does naming the data alone produce an empty plot?

Because the plot has been told which table to draw from and not yet what to draw. The geometry is what puts marks on the canvas, so an empty frame confirms the first step worked rather than signalling an error.

What does the aesthetic mapping actually do?

It decides which column becomes the horizontal axis, which becomes the vertical, and which one drives colour or fill. It never carries a number you typed in yourself, which is what separates mapping a variable from setting a constant.

Why did every point come out the same colour?

Almost always because the grouping column was set as a fixed value outside the mapping, so it applies uniformly to every point. Moving it inside the mapping makes the colour vary with the data and produces the legend that names the groups.

Study strategy

Exam move

Practise the four-step build by hand until you can write a plot call without a console. Then practise the reverse: given a plot call, say what the chart will show and which question it answers. Keep a short list of the four standard chart answers and the question each one belongs to.

Recalling the list is faster under exam conditions than reasoning from scratch, and it prevents the most common error, which is drawing a count where a mean was wanted.

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

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