Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to define all Sweave options in code?

Tags:

r

sweave

Quoting from the pgfSweave manual:

How do I set subdirectories for gures and caches? This is straight out of the Sweave and cacheSweave manuals (nothing new here). For a figures subdirectory use the prefix.string option:

\SweaveOpts{prefix.string=figs/fig}

For a caching subdirectory use a code chunk at the beginning or your document like:

<<setup,echo=F>>=
setCacheDir("cache")
@

I find it annoying that the two options are in different places, R code vs. latex directive. Is there a way to set the prefix.string option with R code, perhaps before Sweave is called?

like image 262
Andrew Redd Avatar asked Oct 10 '22 18:10

Andrew Redd


1 Answers

Sweave options can be set globally either by using \SweaveOpts or in the call to Sweave, like this:

Sweave("tmp.Rnw", prefix.string="figs/figs")
like image 186
Aaron left Stack Overflow Avatar answered Oct 13 '22 11:10

Aaron left Stack Overflow