Skip to main content

Section 5.5 Visualizing Relationships

When we have categorical and numeric data, there are two visualizations that are extremely relevant when visualizing our data: boxplots and bar charts (see Subsubsection 3.4.3.1 for a quick review on bar charts).
ggplot(memory, aes(x = method, y = score, fill = method)) +
  geom_boxplot(alpha = 0.7) +
  labs(
    title = "Memory Test Scores by Study Technique",
    x = "Study Technique",
    y = "Memory Test Score"
  ) +
  theme_minimal()
Three side-by-side boxplots showing memory test score distributions for Flashcards, Rereading, and Testing study techniques. Testing shows the highest median score, while Rereading shows the lowest.
Figure 5.5.1. Boxplots showing the distribution of memory test scores for each study technique, highlighting differences in central tendency and variability across groups.
memory |>
  group_by(method) |>
  summarize(mean_score = mean(score)) |>
  ggplot(aes(x = method, y = mean_score, fill = method)) +
  geom_col() +
  geom_text(aes(label = round(mean_score, 1)), vjust = -0.5) + # adds the means to bars
  labs(
    title = "Average Memory Score by Study Technique (ANOVA Means)",
    x = "Study Technique",
    y = "Average Score"
  ) +
  theme_minimal()
A bar chart showing average memory test scores for Flashcards (76.1), Rereading (69.5), and Testing (85.7) study techniques, with count labels above each bar.
Figure 5.5.2. Average memory test scores by study technique. While differences in group means are apparent, statistical significance is assessed using a one-way ANOVA rather than visual inspection alone.