Skip to main content

Section 3.1 Introduction

Whoever said a picture is worth 1,000 words severely understated how many words a picture is actually worth. When working with data, there is a strong argument to make that nothing is more important than visuals.

If there is one piece of advice to take from this textbook, it is this:.

After running summary statistics, always visualize your data!
You may be thinking β€œhow powerful can a visualization even be?” That is a great question, that Anscombe’s quartet will help answer ([D.1.22]).
Quick history lesson. In 1973 (before the invention of R), a statistician named Francis Anscombe created four unique datasets, which all had identical summary statistics.
library(tidyverse)
library(quartets)
library(knitr)

anscombe_quartet |>
  group_by(dataset) |>
  summarise(mean_x = mean(x),
            variance_x = var(x),
            mean_y = mean(y),
            variance_y = var(y),
            correlation = cor(x, y)) |>
  kable(digits = 2,caption = "A breakdown of summary statistics from the four individual datasets Anscombe created.")
Table: A breakdown of summary statistics from the four individual datasets Anscombe created.

|dataset     | mean_x| variance_x| mean_y| variance_y| correlation|
|:-----------|------:|----------:|------:|----------:|-----------:|
|Anscombe I  |      9|         11|    7.5|       4.13|        0.82|
|Anscombe II |      9|         11|    7.5|       4.13|        0.82|
|Anscombe III|      9|         11|    7.5|       4.12|        0.82|
|Anscombe IV |      9|         11|    7.5|       4.12|        0.82|
As the table above shows, all four of the different datasets show the same means, variances, and correlations (more on that in chapter 6). With just these summary statistics, you’d likely think β€œeh, all the data is the same, these datasets are basically identical.”
Wrong.
When we graph these four datasets, we see something totally different than what the table shows.
ggplot(anscombe_quartet, aes(x = x, y = y)) +
  geom_point() + 
  geom_smooth(method = "lm") +
  facet_wrap(~dataset)
Four scatter plots arranged in a 2x2 grid showing Anscombe I through IV. Each has a linear trend line, but the point patterns differ dramatically: I is roughly linear, II is curved, III is linear with one outlier, and IV has all points at one x-value except one.
Figure 3.1.1. While the four datasets looked identical in the table, the visualized Anscombe datasets show an entirely different picture.
With our visualization, we are introduced to an entirely different way of seeing our data. The table showed that the summary statistics were identical, but here we can see:
  1. Dataset One has a linear relationship between x and y.
  2. Dataset Two has a nonlinear relationship between x and y.
  3. Dataset Three, while still linear, has an outlier.
  4. Dataset Four shows something totally different from the rest!
Visualizations provide insights into data that sometimes numbers can’t show.
This chapter is meant less to be a lesson, and more to be a reference page to come to when you need to make graphs. You do not need to remember every plotting option shown here. This chapter is designed to be returned to whenever you need a reminder or example.