One thin line per subject with an optional bold group mean overlaid — the standard way to show within-subject change without hiding spread.
geom_spaghetti(
mapping = NULL,
data = NULL,
mean_line = TRUE,
alpha = NULL,
linewidth = NULL
)A Layer to add with +.
set.seed(1)
d <- data.frame(
week = rep(0:4, 8), id = rep(1:8, each = 5),
score = as.vector(sapply(1:8, function(i) 50 + i + (0:4) * 2 + rnorm(5, 0, 3)))
)
ggnext(d, aes(week, score, group = id)) + geom_spaghetti()
#> <ggnext plot>
#> data: 40 x 3
#> aes: x = week, y = score, group = id
#> layers: 1
#> coord: cartesian
#> mode: static