julia.jacobson at arcor.de
2012-Apr-26 14:29 UTC
[R] Sweave: Avoiding recompilation of figures
Hello everybody out there using Sweave, There are some complicated SQL queries and laborous calculations against large data included as R code chunks using Sweave in my LaTeX document. These code chunks create graphs that do not change most of the time, but they are of course recompiled every time I run Sweave on my file for update of minor changes to the LaTeX text. Is there an option implemented in Sweave allowing for avoidence of recompilation of already existing figures? Thanks in advance, Julia
The easiest way probably is to put the code that takes so long to execute, in a separate file, such as "graph1.Rnw", and get it into your master file via SweaveInput( "graph1.Rnw" ). Once you are happy with your graph1, you can comment this line out and only compile the stuff that keeps changing. Of course, there are more general methods available: Check out http://cran.r-project.org/web/packages/cacheSweave/ Another way around re-compiling would be using make http://cgibbons.berkeley.edu/Research/Papers/MakefileTutorial.pdf As a modern replacement for Sweave http://cran.r-project.org/web/packages/knitr/index.html seems to be the thing to watch. Personally, I'm still putting up with some waiting time, rather than moving up the learning curve, but I'm sure one of these three will meet your requirement. Rgds, Rainer On Thursday 26 April 2012 16:29:28 julia.jacobson at arcor.de wrote:> Hello everybody out there using Sweave, > > There are some complicated SQL queries and laborous calculations against large data included as R code chunks using Sweave in my LaTeX document. > These code chunks create graphs that do not change most of the time, but they are of course recompiled every time I run Sweave on my file for update of minor changes to the LaTeX text. > Is there an option implemented in Sweave allowing for avoidence of recompilation of already existing figures? > > Thanks in advance, > Julia > > ______________________________________________ > 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.