Skip to content

Instantly share code, notes, and snippets.

@mattansb
Created October 29, 2024 11:11
Show Gist options
  • Save mattansb/6e9e29978f0421aa2194f89dfeb2e345 to your computer and use it in GitHub Desktop.
Save mattansb/6e9e29978f0421aa2194f89dfeb2e345 to your computer and use it in GitHub Desktop.
library(ggplot2)

temp <- tempfile()
download.file("https://www.pilesofvariance.com/Chapter6/SPSS/SPSS_Chapter6.zip", temp)
dataset <- haven::read_sav(unz(temp, "SPSS_Chapter6/SPSS_Chapter6.sav"))
unlink(temp)



ggplot(dataset, aes(session, rt))+
  stat_smooth(aes(color = factor(PersonID)), 
              se = FALSE,
              alpha = 0.9, show.legend = FALSE) +   
  geom_point(color = "#b65944", position = position_jitter(0.3)) + 
  scale_color_manual(
    values = sample(c("#c9190e", "#ccba82", "#daca89", "#d2c291", "#c8b04f"), 
                    size = 101, replace = TRUE)
  ) + 
  scale_x_continuous("Session", breaks = 1:6) + 
  scale_y_continuous("Reaction Time", labels = scales::label_comma()) + 
  theme_bw() + 
  labs(caption = glue::glue("Data from {N} people, over 6 sessions.",
                            N = nlevels(factor(dataset$PersonID))))
#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

Created on 2024-10-29 with reprex v2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment