[Rd] lattice and Sweave

Thomas Lumley tlumley at u.washington.edu
Thu Jun 19 12:58:27 MEST 2003


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



More information about the R-devel mailing list