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

Rolf Turner r@turner @ending from @uckl@nd@@c@nz
Sat Apr 14 02:25:56 CEST 2018


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

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276




More information about the R-help mailing list