# Snippet exactly as printed on the page
library(ggplot2)
d <- read.csv("superplot_data.csv")
reps <- aggregate(speed ~ experiment + condition, data = d, FUN = mean)   # one mean per experiment
w <- reshape(reps, idvar = "experiment", timevar = "condition", direction = "wide")
t.test(w$speed.drug, w$speed.control, paired = TRUE)                     # n = experiments

ggplot(d, aes(condition, speed, colour = experiment, shape = experiment)) +
  geom_point(position = position_jitter(width = 0.25, height = 0, seed = 1), alpha = 0.45) +
  geom_line(data = reps, aes(group = experiment)) +
  geom_point(data = reps, size = 4.5, stroke = 1, colour = "black", aes(fill = experiment)) +
  stat_summary(data = reps, aes(condition, speed), fun = mean, geom = "crossbar",
               width = 0.5, inherit.aes = FALSE) +
  scale_shape_manual(values = c(21, 22, 24, 23)) +
  theme_classic()
ggsave("page_snippet_R.png", width = 4.2, height = 4.2)
