library(ggplot2)
long <- data.frame(
student = rep(x = 1:12, times = 2),
time = factor(x = rep(x = c("Before", "After"), each = 12), levels = c("Before", "After")),
anxiety = c(before, after)
)
ggplot(data = long, mapping = aes(x = time, y = anxiety, group = student)) +
geom_line(color = "grey60") +
geom_point(size = 3) +
stat_summary(mapping = aes(group = 1), fun = mean, geom = "line",
color = "orange", linewidth = 1.8) +
theme_minimal(base_size = 18) +
labs(
title = "Each Grey Line Is One Student; Orange Is the Group Mean",
x = NULL, y = "Anxiety (0 to 30)"
) +
theme(panel.grid.minor = element_blank())