I love Sweave for writing LaTeX documents with embedded R code, and R’s cacheSweave
package helps tremendously in avoiding repetition of time-consuming computations. (Thank you, Roger Peng, for writing cacheSweave!) One catch that is evident from a careful perusal of the cacheSweave
vignette but which I keep forgetting is that cacheSweave
will not cache R code chunks with side effects! Side effects include (but are not limited to):
print()
and related display-to-screen commandsplot()
and other graphical-output commands
This failure to cache is silent, so it can be confusing; I keep on forgetting about it. So this post is as much as anything else a note to myself to remember. The simple solution is to separate out the long-computation chunks from the side-effect chunks and cache only the former (see the vignette for details).
Post a Comment
You must be logged in to post a comment.