This question was answered 2 years ago but it doesn't work in a strange way:
Adding points to horizontal boxplots
My data frame is eight columns of scores of test data. So, each column represents one student and their nine different test scores. I would like a box plot for each student all on the same plot.
When I use the given commands shown in the answer, I do get beautiful mean points on each of the eight horizontal box plots for my data frame but the mean points are incorrectly on the wrong box plot. This is very weird. There is no rhyme or reason for why this is--it's not like the means got shifted backwards and forwards or got shifted in some logical way.
When I use ggplot and geom_boxplot, the mean points are correctly plotted. So, I've been using ggplot and geom_boxplot. But I'm very curious (and in some ways, disturbed) that plotting the mean points over a box plot gives me the correct means but on the incorrect box.
Here is my data:
mydata <- data.frame(var1=c(100, 56, 100, 100, 100, 100, 100, 83, 100),
var2=c(100, 100, 100, 100, 50, 75, 100, 100, 100),
var3= c(100, 100, 100, 100, 100, 100, 30, 100, 100),
var4= c(100, 100, 100, 100, 100, 100, 100, 100, 100),
var5= c(80, 60, 100, 100, 100, 50, 100, 100, 100),
var6= c(100, 50, 25, 17, 75, 14, 25, 100, 100),
var7= c(100, 100, 100, 33, 100, 100, 67, 100, 83),
var8= c(88, 79, 100, 40, 22, 100, 33, 75, 57))
# Here is me trying the answer that was given two years ago,
# which works but plots out mean points like there is a poltergeist in R:
boxplot(mydata, horizontal=TRUE)
means<-colMeans(mydata)
points(means,order(means),pch=18,col="red")
Any help/comments/suggestions would be much appreciated. Even if the comments are, "Who cares? Just use ggplot. It's better and it works!" I'm still learning R so ANYTHING is useful to me. Right now I feel like I should use ggplot for everything, regardless of how quickly and how many times I need to visualize my data.