[R] Sweave: Avoiding recompilation of figures

Yihui Xie xie at yihui.name
Thu Apr 26 18:07:40 CEST 2012


I guess there is not a steep learning curve if you want to use cache
in knitr or cacheSweave -- just use the chunk option cache=TRUE and
you are all set.

<<heavy-chunk, cache=TRUE>>=
# time-consuming computation here
@

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA


On Thu, Apr 26, 2012 at 10:52 AM, Rainer Schuermann
<rainer.schuermann at gmx.net> wrote:
> 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
>>



More information about the R-help mailing list