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

Duncan Mackay du|c@|m@ @end|ng |rom b|gpond@com
Sat Apr 28 03:04:18 CEST 2018


Hi Paul, Rolf

I do not know how legal this is but this works if you have spaces around the ultimate plot due to changes in layout
Changing the layout parameters removes the unwanted space.

ap = dotplot(variety ~ yield | year * site, data=barley,layout = c(2,6))
apm = ap[1:2,3:4]
apm$layout <- c(2,2)
apm

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2350


-----Original Message-----
From: R-help [mailto:r-help-bounces using r-project.org] On Behalf Of Paul Murrell
Sent: Friday, 27 April 2018 11:28
To: Rolf Turner
Cc: r-help using r-project.org; deepayan.sarkar using r-project.org
Subject: Re: [R] [FORGED] Extracting specified pages from a lattice ("trellis") object.

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/

______________________________________________
R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
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