From: Chuck Cleland <ccleland_at_optonline.net>

Date: Sat 06 May 2006 - 20:11:20 EST

*>
*

> I could get mean as dot symbol but i need values too? Also how to print the x-axis labels vertically instead of horizontally? Is there any other function to achieve these?

Date: Sat 06 May 2006 - 20:11:20 EST

Sachin J wrote:

*> Hi,
**>
*

> How can I get the values of mean and median (not only points but values too) on the boxplot. I am using boxplot function from graphics package. Following is my data set

*>
**> > df
**> [1] 5 1 1 0 0 10 38 47 2 5 0 28 5 8 81 21 12 9 1 12 2 4 22 3
**>
**> > mean.val <- sapply(df,mean)
*

>> boxplot(df,las = 1,col = "light blue") >> points(seq(df), mean.val, pch = 19)

> I could get mean as dot symbol but i need values too? Also how to print the x-axis labels vertically instead of horizontally? Is there any other function to achieve these?

A few ideas to try:

df <- c(5, 1, 1, 0, 0, 10, 38, 47, 2, 5, 0, 28, 5, 8, 81, 21, 12, 9, 1,
12, 2, 4, 22, 3)

boxplot(df, las=1, col="light blue")

points(1, mean(df), pch=19)

text(0.75, mean(df), paste("Mean =", round(mean(df), 2)), adj=1)
text(1.25, median(df), paste("Median =", round(median(df), 2)), adj=0)

boxplot(df, las=1, col="light blue")

points(1, mean(df), pch = 19)

text(0.75, mean(df), round(mean(df), 2), adj=1)
text(1.25, median(df), round(median(df), 2), adj=0)

mydf <- data.frame(A=runif(100), B=runif(100), C=runif(100), D=runif(100))
par(mar=c(8,5,5,5))

boxplot(mydf, las=1, col="light blue")

points(seq(mydf), colMeans(mydf), pch=19)

mtext(side=1, line=2, at=seq(mydf), paste("Mean =", round(colMeans(mydf),2))) mtext(side=1, line=3, at=seq(mydf), paste("Median =", round(apply(mydf,2, median),2)))

Also, see bp.example() in the following post:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/3158.html

-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlReceived on Sat May 06 20:19:21 2006

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Sat 06 May 2006 - 22:09:59 EST.

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