[R] {ggplot2} Adding Mean to (grouped) Boxplot.
Peng Cai
pengcaimaillist at gmail.com
Thu Nov 26 22:00:59 CET 2009
Hi R Users,
I am using following R code to plot a "grouped boxplot". I'm hoping if I can
add MEAN to these boxplots. Data is copied below and attached as text file.
install.packages("ggplot2")
library(ggplot2)
dta<-read.table("Sample.txt",header=T)
attach(dta)
p <- ggplot(dta, aes(factor(month), nail))
p + geom_boxplot(aes(fill = factor(trt)))
Data:
month nail trt
6 7.2 1
12 9.3 1
0 5.8 1
1 6 1
2 6.5 1
3 7 1
6 9.1 1
12 7.9 1
0 3.3 1
1 4.9 1
2 1.4 2
3 2.7 2
6 3.7 2
12 9.4 2
0 3.1 2
1 2.7 2
2 5.4 2
3 8.3 2
6 12.3 2
12 17.7 2
Any help would be greatly appreciated,
Thanks,
Peng
-------------- next part --------------
month nail trt
6 7.2 1
12 9.3 1
0 5.8 1
1 6 1
2 6.5 1
3 7 1
6 9.1 1
12 7.9 1
0 3.3 1
1 4.9 1
2 1.4 2
3 2.7 2
6 3.7 2
12 9.4 2
0 3.1 2
1 2.7 2
2 5.4 2
3 8.3 2
6 12.3 2
12 17.7 2
More information about the R-help
mailing list