[R] [FORGED] Extracting specified pages from a lattice ("trellis") object.

Paul Murrell p@u| @end|ng |rom @t@t@@uck|@nd@@c@nz
Fri Apr 27 03:27:35 CEST 2018


Hi

Does this not do what you want ... ?

allpages <- dotplot(variety ~ yield | year * site, data=barley,
                     layout=c(2,2))
page2 <- allpages[1:2, 3:4]
print(page2)

Paul

On 24/04/18 17:51, Rolf Turner wrote:
> 
> On 24/04/18 15:17, Paul Murrell wrote:
> 
>> Hi
>>
>> I think the subsetting works by giving you the panels for the 
>> corresponding levels of the conditioning variable(s).  Note that, if 
>> there is more than one conditioning variable, you will need more than 
>> one subsetting index.
>>
>> For example, taking this plot with two conditioning variables and 12 
>> panels in total ...
>>
>> dotplot(variety ~ yield | year * site, data=barley)
>>
>> ... this produces three pages ...
>>
>> dotplot(variety ~ yield | year * site, data=barley,
>>          layout=c(2,2))
>>
>> ... and this produces the second page (both panels for the first 
>> conditioning variable and the third and fourth panels for the second 
>> conditioning variable) ...
>>
>> dotplot(variety ~ yield | year * site, data=barley,
>>          layout=c(2,2))[1:2, 3:4]
>>
>> Hope that helps.
> 
> Hmm.  Thanks Paul.  I may be able to work with that.  But what I really 
> wanted was to take
> 
>      bar <- dotplot(variety ~ yield | year * site, data=barley)
> 
> and then do (something like)
> 
>      foo <- bar[<something>]
> 
> so that foo contains only the second page of bar, and then do print(foo)
> to get a plot of (just) the second page.  Without re-issuing a 
> (modified) plot command.
> 
> Is that not at all possible?
> 
> cheers,
> 
> Rolf.
> 

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul using stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/




More information about the R-help mailing list