Re: [R] An example of the boxplot thickness problem

From: Kenneth Roy Cabrera Torres <krcabrer_at_une.net.co>
Date: Wed, 12 Nov 2008 04:56:04 -0500

Dr. Sarkar:

Thank you very much for your help!

Is there any problem that it shows this warning message?

Warning messages:
1: In levels.fos - blist.height/2:

    Length of object is greater or is not multiple     of the length of the shortest.
2: In levels.fos - blist.height/2:

    Length of object is greater or is not multiple     of the length of the shortest.

El mar, 11-11-2008 a las 21:21 -0800, Deepayan Sarkar escribió:
> On 11/11/08, Kenneth Roy Cabrera Torres <krcabrer@une.net.co> wrote:
> > Hi R users:
> >
> > I reproduce the problem that I have with the
> > boxplot thickness:
> > ------------------------------------------------------------------
> > # A data frame:
> > set.seed(123)
> > cont1<-c(rnorm(10,1),rnorm(5,3),rnorm(12,5),rnorm(14,3),rnorm(4,5))
> > categ1<-factor(c(rep("A",10+5+12),rep("B",14+4)))
> > categ2<-c(rep("Z",10),rep("Y",5),rep("X",12),rep("Y",14),rep("X",4))
> >
> > data1<-data.frame(cont1,categ1,categ2)
> >
> > # This is the variable that I want that each boxplot
> > # be thickness proportional. (could be any other, the only
> > # condition is that I have a number (or NA) for each combination of the
> > # two categorical variables).
> > cont2<-tapply(cont1,list(categ1,categ2),length)/length(cont1)
> >
> > require(lattice)
> > # This is the standard boxplot
> > bwplot(categ2~cont1|categ1,data=data1)
> > # I try:
> > bwplot(categ2~cont1|categ1,box.ratio=cont2,data=data1)
> > # This one also
> > bwplot(categ2~cont1|categ1,box.ratio=t(cont2),data=data1)
> > ----------------------------------------------------------------
> >
> > Problems:
> > 1. I expect that the boxplot for the B and Y combination
> > would be the most thick, and in second place the A and X
> > and the last the X and B combination.
>
> I think you want something like
>
> bwplot(categ2 ~ cont1 | categ1, data=data1,
> panel = function(..., box.width) {
> panel.bwplot(...,
> box.width = as.numeric(cont2[packet.number(), ]))
> })
>
> > 2. Why the other lines in the box of the boxplot?
>
> You are providing 6 width values for 3 boxes in each panel; the values
> are being recycled and each box is being drawn twice, with different
> widths.
>
> -Deepayan



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 12 Nov 2008 - 09:58:10 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 12 Nov 2008 - 16:30:24 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