Hi I want to ask how to plot paired data connected with lines in ggplot across multiple groups? Some sample data to work with:
set.seed(123)
sample <- data.frame(name = c(rep("Amy",4),rep("Bob",4),rep("Jack",4)),
status = rep(c("Before","After"),6),
test = rep(c("English","English","Math","Math"),3),
score = sample(60:100,12,replace=T))
sample %>% ggplot(aes(x=test,y=score,fill=status)) +
geom_boxplot() + geom_point(size = 2)
The idea is to have the test on the x-axis and score on the y axis as shown below but instead of having a boxplot, the individual geom_point() are stratified by status group (so points that are in the after group are in the space where the red boxplot is and points that are in the before group are in the space where the blue boxplot is) with geom_line() connecting the paired data points from the same name. Thanks!


