From tlumley at u.washington.edu  Thu Jun 19 12:58:27 2003
From: tlumley at u.washington.edu (Thomas Lumley)
Date: Thu Jun 19 20:58:38 2003
Subject: [Rd] lattice and Sweave
Message-ID: <Pine.A41.4.44.0306191128490.97770-100000@homer37.u.washington.edu>


I'm having trouble using lattice and Sweave together.

An example of the trouble is the chunk

<<fig=true, eps=false>>=
library(nlme)
data(Orthodont)
plot(Orthodont)
@

This gives a warning

Warning message:
No Active Device, using default values in: trellis.par.get("add.text")

 and creates a pdf file with no pages.

I think this is related to the fact that a figure chunk is evaluated
twice, once with no device open.  Possibly related anomalies include the
fact that you end up with a theme set for the null device:
> names(lattice.theme)
[1] "null device" "postscript"  "pdf"
which doesn't look right.

The chunk
<<>>=
library(lattice)

 data(airquality)
 windspeed<-equal.count(airquality$Wind, 4)
 temperature<-equal.count(airquality$Temp, 4)

 print(xyplot(Ozone~Solar.R|windspeed*temperature, data=airquality,
col="darkred"))
@

works fine, so I think the problem is related to using trellis.par.get
before setting a trellis device.


	-thomas


[Rd] lattice and Sweave
Thomas Lumley