[R] Odp: Multifactor boxplots

Petr PIKAL petr.pikal at precheza.cz
Fri Jul 29 14:05:03 CEST 2011


Hi

> 
> Dear All
> 
> I would like to produce interaction boxplots and this seems to work:
> 
> par(mfrow=c(2,2))
> A=sample(rnorm(50,50,10))
> B=sample(rnorm(50,100,10))
> Test=merge(A,B,by=0)#by=0 where 0 is the row.names
> TreatA=(gl(2,50,100,labels=c("High","Low")))
> TreatB=rep(gl(2,25,50,labels=c("High","Low")),2)
> Newdata=data.frame(TreatA,TreatB,Test)
> 
> bwplot(x~TreatA:TreatB,data=Newdata)
> 
> However, I would prefer the X axis labels to be different, such that 
there
> are two label rows (TreatA and TreatB) something like this:
> 
> TreatA    High     High    Low       Low
> TreatB    High     Low     High      Low
> 
> any guidance on achieving this much appreciated.

Combination of axes=FALSE

boxplot(x~TreatA:TreatB,data=Newdata, axes=F)

and following axis and mtext commands seems to do what you want
axis(2)
axis(1, at= 1:4,labels=c("H", "H", "L", "L"))


Regards
Petr

>

> 
> Regards
> 
> Tom
> 
> 
>    [[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.



More information about the R-help mailing list