Re: [R] An array of an array of boxplots in lattice

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Mon, 17 Nov 2008 11:35:59 -0800

On Mon, Nov 17, 2008 at 11:15 AM, Chuck Cleland <ccleland_at_optonline.net> wrote:
> On 11/17/2008 1:50 PM, steve wrote:
>> Using the data set fgl in MASS the following code
>>
>> layout(matrix(1:9,3,3))
>> for(i in 1:9){
>> boxplot(fgl[,i] ~ type, data = fgl,main=dimnames(fgl)[[2]][i])}
>>
>> produces a 3 by 3 array of plots, each one of which consists of six
>> boxplots.
>>
>> Is it possible to do this in lattice?
>
> library(MASS)
> library(lattice)
>
> newdf <- reshape(fgl, varying =
> list(c('RI','Na','Mg','Al','Si','K','Ca','Ba','Fe')),
> v.names = 'Y',
> times=c('RI','Na','Mg','Al','Si','K','Ca','Ba','Fe'),
> direction='long')

And a slightly less verbose version of this step is:

newdf <- do.call(make.groups, fgl[-10])
newdf$type <- fgl$type

followed by

bwplot(data ~ which | type, data = newdf, <etc.>)

-Deepayan

> bwplot(Y ~ type | time, data = newdf, ylab="",
> scales=list(y=list(relation='free')))
>
>> Steve
>>
>> "R version 2.7.2 (2008-08-25)" on Ubuntu 6.06
>>
>> ______________________________________________
>> 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.
>
> --
> Chuck Cleland, Ph.D.
> NDRI, Inc. (www.ndri.org)
> 71 West 23rd Street, 8th floor
> New York, NY 10010
> tel: (212) 845-4495 (Tu, Th)
> tel: (732) 512-0171 (M, W, F)
> fax: (917) 438-0894
>
> ______________________________________________
> 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 Mon 17 Nov 2008 - 19:40:58 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 Mon 17 Nov 2008 - 22:30:26 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