Re: [R] boxplot and number of observations per box

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Wed, 30 Jan 2008 08:52:45 -0500

Here is a variation in which the sample sizes appear under the labels:

set.seed(1)
y <- rnorm(50)
x <- factor(sample(letters[1:5], 50, replace = TRUE)) bp <- boxplot(y ~ x, varwidth = TRUE)
mtext(paste("(n=", bp$n, ")", sep = ""), at = seq_along(bp$n), line = 2, side = 1)

On Jan 30, 2008 7:30 AM, S Ellison <S.Ellison_at_lgc.co.uk> wrote:
> Do you mean something like
>
> y<-rnorm(50)
> x<-factor(sample(letters[1:5],50,replace=T))
> boxplot(y~x)
> text(1:5,rep(min(y),5),paste("n=",tapply(y,x,length)) )
> ?
> (You can fiddle about with the text placement easily enough).
>
> Also note that boxplot's varwidth parameter provides a graphical
> indication of group size;
> boxplot(y~x, varwidth=T)
>
>
>
>
> >>> Marc Bernard <bernarduse1_at_yahoo.fr> 30/01/2008 11:43:15 >>>
> Dear all,
>
> How can I plot the number of observations per box in a boxplot. Many
> thanks,
>
> Bernard
>
>
>
>
> ---------------------------------
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
> *******************************************************************
> This email and any attachments are confidential. Any use...{{dropped:8}}
>
>
> ______________________________________________
> 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.
>



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 Wed 30 Jan 2008 - 14:03:14 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 Wed 30 Jan 2008 - 14:30:09 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