[R] [FORGED] Extracting specified pages from a lattice ("trellis") object.
Paul Murrell
p@u| @end|ng |rom @t@t@@uck|@nd@@c@nz
Tue Apr 24 05:17:41 CEST 2018
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
Paul
On 14/04/18 12:25, Rolf Turner wrote:
>
> Suppose that (e.g.) xyplot() returns an object "xxx" with (say) 3 pages.
> I would like to extract/plot (print) just one of these pages, e.g.
> page 2.
>
> Here's a toy example:
>
> x <- rep(seq(0,1,length=11),12)
> set.seed(42)
> y <- rnorm(3*44)
> a <- rep(letters[1:12],each=11)
> dta <- data.frame(x=x,y=y,a=a)
> xxx <- xyplot(y~x|a,data=dta,layout=c(2,2))
>
> I would to extract from xxx and print page 2 (the page corresponding to
> levels e, f, g and h).
>
> Is there any (simple) way that I can do this?
>
> I've mucked around with update.trellis() and [.trellis, but I cannot
> make head nor tail of the documentation. The [.trellis method seems to
> work in some situations, but not in others, and since I cannot
> understand what it actually does, I cannot figure out why.
>
> E.g. in my toy example "xxx[5:8]" seems to give me what I want, but in
> the context of my real application a similar construction does not work.
>
> Thanks for any insight.
>
> cheers,
>
> Rolf Turner
>
--
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