Assess + visualize · Week 09

Midterm + Visualization

After the October 19 midterm, begin data visualization with Lecture 7. Build your first ggplot2 histograms, connect the code to the chart, and describe a numeric distribution in Classwork 10.

Oct 19–23Midterm completed · Oct 19Visualization begins · Oct 21
ImportantStart visualization here

Start Lecture 7 from the beginning, then complete Classwork 10: Distribution of a Numeric Variable. Use the built-in mpg data to make histograms of city fuel economy, compare bin widths, and explain the patterns you see.

Focus

  • A chart begins with a question
  • Data, aesthetic mappings, and geoms
  • Histograms and distribution shapes

Prepare

  • Start Lecture 7 at the title slide
  • Open an R script and load tidyverse
  • Have Classwork 10 ready; no CSV import is needed

Practice

  • Plot city fuel economy from mpg
  • Compare 1-MPG and 5-MPG bin widths
  • Explain the axes, peaks, and tails

Learning targets

  • State a question that a chart can help answer.
  • Identify the data frame, aesthetic mapping, and geom in a ggplot() expression.
  • Build a histogram of a numeric variable with geom_histogram().
  • Explain what the horizontal axis represents and what each bar’s height counts.
  • Compare how different bin widths reveal or hide detail in the same data.
  • Describe a distribution’s peaks and longer tail without confusing the tail with the tallest bars.

Core pattern: a numeric distribution

library(tidyverse)

ggplot(data = mpg,
       mapping = aes(x = cty)) +
  geom_histogram(binwidth = 2) +
  labs(x = "City fuel economy (MPG)",
       y = "Number of vehicle configurations")

Each row in mpg represents a vehicle model configuration, and cty records city fuel economy in miles per gallon. The histogram groups these values into bins and counts the rows in each bin; no variable needs to be mapped to y.

In Classwork 10, change the bin width to 1 and 5, compare the resulting charts, and describe their peaks and tails. The data stay the same even when the visible detail changes.

Lecture slides

TipLecture slide shortcuts

Click inside the slide preview, then use:

  • the visible ←/→ controls to page through the slides;
  • your mouse wheel or trackpad to keep scrolling the weekly page;
  • M to open the menu;
  • F to enter fullscreen;
  • E to enter or exit PDF export mode;
  • Ctrl + Shift + F to search within the slides;
  • Esc to exit the menu or fullscreen; and
  • T to switch between dark and light mode.
Lecture 7 · Data Visualization I: Distributions and Group Comparisons · start from the beginningView slides in new tab

This week’s materials

Back to top