Re: [R] adding the mean and standard deviation to boxplots

From: Felipe Carrillo <mazatlanmexico_at_yahoo.com>
Date: Tue, 5 Feb 2008 10:58:40 -0800 (PST)


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

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 05 Feb 2008 - 19:00:43 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 05 Feb 2008 - 19:30:14 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive