[R] beamer overlays with Sweave?

From: Ben Bolker <bbolker_at_gmail.com>
Date: Mon, 07 Mar 2011 22:20:49 -0500

  This may be asking too much, but I'm wondering if anyone has a solution (even a hack) for creating multiple (overlay) plots in an Sweave file and post-processing the overlays in beamer appropriately.

  For example, suppose I have a series of figure blocks in my .Rnw file:

<<plot1,fig=TRUE>>=
[stuff]
@
<<plot2,fig=TRUE>>=
[stuff]
@
<<plot3,fig=TRUE>>=
[stuff]
@

  These three blocks create three figures that I want to have appear as a series of overlays in the final PDF file.

  Sweave outputs the following LaTeX code:

\includegraphics{plot1}
\includegraphics{plot2}
\includegraphics{plot3}

  and I need to turn it into

\only<1>{\includegraphics{plot1}}
\only<2>{\includegraphics{plot2}}
\only<3>{\includegraphics{plot3}}

  I have few enough of these that I've been modifying them by hand (couldn't easily come up with the appropriate sed/awk incantation); it works, but it's annoying and error-prone. I could spend some more time hacking it, but I wondered if anyone else had already solved this ...

  (Brief googling of "beamer+Sweave+overlay" didn't find an obvious answer, but I might have missed something ...)

  thanks
    Ben Bolker



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 08 Mar 2011 - 03:23:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 08 Mar 2011 - 13:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive