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

From: steve <fisk_at_bowdoin.edu>
Date: Mon, 17 Nov 2008 16:42:17 -0500

library(reshape)
fgl2 = melt(fgl[,-10])
fgl2\$type = fgl\$type
bwplot(value ~ type | variable, data = fgl2)

Steve

Deepayan Sarkar wrote:

```> 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 - 21:45:00 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 - 23:30:28 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.