In-Class Exercise 3
Shih Chien University
2026-08-03
Using the economics dataset, make two plots of the unemployment rate over time (x = date, y = unemploy / pop): one with geom_line() and one with geom_point(). Then make a bar chart of the number of cars in each class of the mpg dataset using geom_bar().
Write one sentence explaining why a line is the right geom for the unemployment series but a bar is the right geom for the class counts.
Using the economics dataset, plot unemploy / pop against uempmed (median duration of unemployment) with geom_path(). Compare it with the same plot drawn with geom_line().
Write one sentence explaining the difference: which geom connects observations in the order they appear in the data (time order), and why that matters for showing how the economy evolved.
Using the mpg dataset, plot displ vs hwy with one smooth line per vehicle class. First try mapping colour = class inside aes(), then try a version where the points are a single colour but you add geom_smooth(aes(group = class), se = FALSE). Combine points and smooths as multiple geoms in one plot.
Write one sentence explaining what the group aesthetic does when you do not want a separate colour (or legend) for each group.
Complete your answers in the official template from the Problem sets page (author = your student ID only; keep the UUID chunk). Knit to PDF, name it ex3-[StudentID].pdf, and upload it to the course pCloud folder before midnight of the following week.
ggplot2: Elegant Graphics for Data Analysis