[R] boxplot and stripchart

Göran Broström goran.brostrom at gmail.com
Fri Oct 10 16:37:18 CEST 2008


On Fri, Oct 10, 2008 at 4:24 PM, Peter Dalgaard
<P.Dalgaard at biostat.ku.dk> wrote:
> Göran Broström wrote:
>> I want to make illustrations a la boxplot for a data material with
>> several groups. Some of the groups are very small, so a boxplot
>> doesn't make sense. I would like to use stripchart for these groups.
>> On the other hand, some of the groups are very large, so for them
>> stripchart isn't so good. So my question is: Is it possible to combine
>> boxplots and and stripcharts in one figure? (Of course, in R anything
>> is possible, but I mean in a simple way.) Or is there some other good
>> alternative for a case like this?
>>
>
> Here's a first approximation.
>
> library(ISwR)
> l <- split(juul$igf1,juul$tanner)
> sel <- sapply(l, length) > 100
> boxplot(l[sel],horizontal=TRUE,at=(1:5)[sel], xlim=c(0,6))
> stripchart(l[!sel],at=(1:5)[!sel], add=TRUE)

Elegant, and just what I needed! I had missed the 'at' parameter.

Thanks, Göran

> The y axis needs a bit more diddling.
>
> In this case, I actually find that it is quite sufficint to do
>
> stripchart(igf1 ~ tanner, data=juul, method="jitter", pch=19)
>
> --
>   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
>  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907
>
>
>



-- 
Göran Broström


More information about the R-help mailing list