Tag Archives: Sweave

When your hair is on fire …

I heard a line the other day something like this:

When you’re working with your hair on fire, if you see anything that doesn’t look like a bucket of water, you’re not interested.

I think I heard this on the PowerScripting podcast. The context was a discussion about the design of Microsoft’s PowerShell, a shell and scripting environment targeted for system administrators. The idea was that since many sys admins are working with their hair on fire, PowerShell was designed to look like a bucket of water, something that will bring relief rather than yet another thing to learn.

How can we make reproducible research look like a bucket of water? In the long term, even in the not so long term, reproducibility habits can improve productivity and reduce stress. But many people will not be receptive unless they also see short term benefits, the shorter the better.

I think templates are one way reproducibility can look like a bucket of water to someone with their hair on fire. You’ve got an analysis to do? Here’s a template. Fill in your specifics at the top, compile it, and out comes a beautiful report. Along these lines, at M. D. Anderson we’ve created some Sweave templates for microarray data analysis. One of the things I’d like to see happen on the ReproducibleResearch.org web site is a collection of Sweave templates for statistical analysis. If you have anything to contribute, please send a note.

Reproducible presentations

Yesterday I wrote about my experience trying out Beamer for writing presentations in LaTeX. Some of the images that I’m wanting to include in my presentations are plots produced in R, so one simplification would be to combine Beamer with Sweave. That way I could include code for producing the images directly in my presentation file rather than referencing external image files. Any change to the R code would be automatically reflected in my presentation.

One problem I had when turning a LaTeX Beamer file into a Sweave file was image sizes. When an Sweave file has documentclass{article}, plots are modestly sized and centered. But when I tried including a plot with an Sweave file with documentclass{Beamer}, the image was so large that it covered up other material on the slide. The solution was to include the following line immediately after the begin{document} command:


(See section 4.1.2, page 14 of the Sweave manual.) This command made the image the size I wanted, but the image was no longer centered. To center the image, I added begin{center} before and end{center} after the Sweave figure command. This worked. A sketch of the code is included below.



Slide verbiage ...

<<&fig=TRUE, echo=FALSE>>=
# R code ...