[R] displaying sample size in boxplots

Patrick Drechsler patrick.drechsler at gmx.net
Wed Sep 29 15:39:10 CEST 2004


Hi Marc,

Marc Schwartz wrote on 29 Sep 2004 14:08:19 MET:

> On Wed, 2004-09-29 at 07:46, Patrick Drechsler wrote:
>> I was wondering if there is a ready made function or parameter
>> for indicating the sample size in boxplots?
[...]

> Note that boxplot() returns values, which includes a variety of
> summary information on each group within your data. See the
> "Value" section of ?boxplot and ?boxplot.stats for more
> information.
>
> Thus, you can do something like (using the first example in
> ?boxplot):
>
> data(InsectSprays)
>
> # Save the returned values from boxplot() in "S"
> S <- boxplot(count ~ spray, data = InsectSprays, col = "lightgray")
>
> # S$n is the sample size for each group
> # S$names contains the group names
> mtext(side = 1, text = S$n, at = 1:length(S$names), line = 2)

Thank you very much--just what I was looking for!

Patrick
-- 
"Ludwig Boltzmann, who spent much of his life studying statistical
mechanics, died in 1906, by his own hand. Paul Ehrenfest, carrying on
the work, died similarly in 1933. Now it is our turn to study
statistical mechanics. Perhaps it will be wise to approach the subject
cautiously."  from "States of Matter" by David Goodstein




More information about the R-help mailing list