Re: [R] boxplot - labelling

From: Joerg van den Hoff <j.van_den_hoff_at_fz-rossendorf.de>
Date: Mon 08 May 2006 - 21:19:36 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?
>
> Thanx in advance.
>
> Sachin
>
>
>
>
> __________________________________________________
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.html

use

par(las = 3)
bxp <- boxplot(df,las = 1,col = "light blue")

to control label orientation and access the data displayed in the boxplot (see `?par', `?boxplot')

use

text(x, y, 'some_text_or_number')

to add text to the boxplot. for x, use the 'number of the box' (i.e. `1' in the example above). for y use the mean or median or whatever you wanted).

joerg



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.html Received on Mon May 08 21:23:15 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 Mon 08 May 2006 - 22:10:02 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.