r - Draw mean and outlier points for box plots using ggplot2 -


i trying plot outliers , mean point box plots in below using data available here. dataset has 3 different factors , 1 value column 3600 rows.

while run below code shows mean point doesn't draw outliers properly

ggplot(df, aes(x=representations, y=values, fill=methods)) +   geom_boxplot() +   facet_wrap(~metrics) +     stat_summary(fun.y=mean, colour="black", geom="point", position=position_dodge(width=0.75)) +   geom_point() +   theme_bw() 

enter image description here

again, while modify code in below mean points disappear !!

ggplot(df, aes(x=representations, y=values, colour=methods)) +   geom_boxplot() +   facet_wrap(~metrics) +     stat_summary(fun.y=mean, colour="black", geom="point", position=position_dodge(width=0.75)) +   geom_point() +   theme_bw() 

enter image description here

in both of cases getting message: "ymax not defined: adjusting position using y instead" 3 times.

any kind suggestions how fix it? draw mean points within individual box plots , show outliers in same colour plots.

edit: original data set not have outliers , reason confusion. mrflick's answer randomly generated data clarifies properly.

rather downloading data, made random sample.

set.seed(18)  gg <- expand.grid (     methods=c("bc","fd","fdfnd","nc"),     metrics=c("dm","dti","lb"),     representations=c("chg","qr","hqr") )  df <- data.frame(     gg,     values=rnorm(nrow(gg)*50) ) 

then should able create plot want with

library(ggplot2)  ggplot(df, aes(x=representations, y=values, fill=methods)) +     geom_boxplot() +     stat_summary(fun.y="mean", geom="point",          position=position_dodge(width=0.75), color="white") +      facet_wrap(~metrics) 

which gave me

boxplot

i using ggplot2 version 0.9.3.1


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -