[R] adding the mean and standard deviation to boxplots

Felipe Carrillo mazatlanmexico at yahoo.com
Tue Feb 5 19:58:40 CET 2008


Tom:
You can do this with ggplot2. The code below puts  95%
CI,a smooth line and the mean(blue point)on the same
plot. 
Felipe

 library(ggplot2)
  r <- ggplot(ToothGrowth, aes(y=len, x=factor(dose)))
  r$background.fill = "cornsilk"
r + geom_boxplot(aes(colour=supp)) +
stat_summary(aes(group=supp),fun="mean_cl_normal",colour="red",geom="smooth",linetype=3,size=1)
+
  
stat_summary(aes(group=supp),fun="mean_cl_normal",colour="blue",geom="point",size=4)

   grid.gedit("label", gp=gpar(fontsize=10,
col="red")) # color the axis labels



Felipe D. Carrillo
  Fishery Biologist
  US Fish & Wildlife Service
  California, USA



      ____________________________________________________________________________________
Be a better friend, newshound, and



More information about the R-help mailing list