Boxplot in R showing average (again)

I saw Boxplot in R showing the average

I'm interested in ggplot solution. But what I'm plotting is averages, so I don't want to do an average on average. I have a true value that is stored in TrueAvgCPC.

Here is what I tried, but it does not work:

p <- qplot(Mydf$Network,Mydf$Avg.CPC,data=Mydf,geom='boxplot')
p <- p+stat_summary(TrueAvgCPC,shape=1,col='red',geom='point')
print(p)

Thank!

+3
source share
1 answer

As far as I can see, you just want to add a true average (or a few?) To the graph of the window. If you have values, why use stat_summary instead of just drawing dots?

#sample data
x <- rnorm(30)
y <- rep(letters[1:3],10)
TrueAVGCPC <- c(0.34,0.1,0.44)

#plot
p <- qplot(y,x,geom='boxplot')
p <- p+geom_point(aes(x=c(1,2,3),y=TrueAVGCPC),col="red")
print(p)
+2
source

Source: https://habr.com/ru/post/1767237/


All Articles