[R] Labelling boxplot with fivenumber summary
Chuck Cleland
ccleland at optonline.net
Fri Apr 6 18:50:15 CEST 2007
Daniel Siddle wrote:
> I am very new to R so forgive me if this seems basic but I have done extensive searching and failed to come up with the answer for myself.
>
> I am trying to label a boxplot I have created with the values for the median, upper and lower quartiles and max and min values. I have been unable to do this or find anything on the net to say how it might be done. Is this possible and if so how? Regards,
Here is another idea:
fn <- boxplot(ToothGrowth$len, plot=FALSE)$stats
par(mar=c(4,6,4,2))
boxplot(ToothGrowth$len, ylab="Length", at=.80)
text(1.15, fn[1], paste("Minimum Value =", fn[1]), adj=0, cex=.7)
text(1.15, fn[2], paste("Lower Quartile =", fn[2]), adj=0, cex=.7)
text(1.15, fn[3], paste("Median =", fn[3]), adj=0, cex=.7)
text(1.15, fn[4], paste("Upper Quartile =", fn[4]), adj=0, cex=.7)
text(1.15, fn[5], paste("Maximum Value =", fn[5]), adj=0, cex=.7)
arrows(1.14, fn[1], 1.02, fn[1])
arrows(1.14, fn[2], 1.02, fn[2])
arrows(1.14, fn[3], 1.02, fn[3])
arrows(1.14, fn[4], 1.02, fn[4])
arrows(1.14, fn[5], 1.02, fn[5])
title("Annotated Boxplot of Tooth Growth")
> Daniel Siddle
>
> ______________________________________________
> R-help at 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.html
> and provide commented, minimal, self-contained, reproducible code.
--
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
More information about the R-help
mailing list