[R] Dynamically switching lattice device characteristics in Sweave under Makefile control

Douglas Bates bates at stat.wisc.edu
Wed Jun 25 00:00:13 CEST 2008

I am indebted to Deepayan Sarkar for lattice graphics, Fritz Leisch
for Sweave and the authors of the beamer package for LaTeX. For me
these are a "killer app" combination.  I wouldn't want to go back to
creating presentations in any other way.

When I create a presentation I use a Makefile that allows me to the
presentation version of the slides, a 4-up version for printing on
letter paper and a 4-up A4 version.  Sample files can be found at

When creating the printable versions I want to invoke something like

lattice.options(default.theme = standard.theme(color = FALSE))

in the "preliminaries" chunk so the 4-up slides can be printed on a
black-and-white printer without losing too much information.  I
haven't worked out a way of passing this information in to the
individual sections yet.  I would welcome suggestions.  If you look in
the Makefile you will see that there is a fooD.tex and a fooH.tex file
controlling whether the display or the other one (I forget why I
called it H) is active.  That is how I control the beamer stuff.  The
problem for me is that the device characteristics need to be
controlled in the individual .Rnw files

Should you be inclined to read the content of the slides (and do bear
in mind that they are a work in progress, to be presented on Sunday) I
will tell you I am particularly proud of the slide entitled
"Definition of linear mixed-effects models" (about slide 13 -
depending on how you count).  In one slide that describes a very
general form of the model.

More information about the R-help mailing list