Module 5 · Lesson 1 of 29/18 in the course~20 min
Module lessons (1/2)
Grammar of Graphs and Geometries
Lesson preview7 hands-on exercises readyCourse R · Module 5 — Viewing with ggplot2
Map variables to coordinates and colors with aes() and overlay geom_point(), geom_line(), and geom_col() layers.
What you'll learn in this lesson
- Understand the three pillars of the Grammar of Graphics: data (
data), aesthetic mappings (aes), and geometric layers (geom_*). - Construct scatter plots (
geom_point()), time series (geom_line()), and bar graphs (geom_col()vsgeom_bar()). - Distinguish between variable-mapped aesthetics inside
aes(color = gender)and fixed aesthetics outsideaes(color = "steelblue"). - Overlay multiple levels on the same chart using the
+operator (e.g. points plus trend linegeom_smooth()).
Overview
The ggplot2 package (inspired by the book The Grammar of Graphics) doesn't force you to choose from a rigid menu of "chart types". Instead, it allows you to combine independent layers connected by the + sign:
ggplot(data, aes(x = ..., y = ...)) + geom_...()
Sections covered in this lesson
- 1Test yourself: guided exercises
- 2Concept check
Pro Lesson · Module 5 — Viewing with ggplot2
Unlock "Grammar of Graphs and Geometries" and the full Course R curriculum
Map variables to coordinates and colors with aes() and overlay geom_point(), geom_line(), and geom_col() layers.
Unlock all 7 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Course R plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.