[R] Sweave and graphic output locations

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Tue Mar 30 21:17:36 CEST 2004


On Tue, 30 Mar 2004 12:31:36 -0500 Max_Kuhn at bd.com wrote:

> 
> Hello,
> 
> I'm using R1.8.1 on windows 2000 and version 1.8.1 of the tools
> package.
> 
> I am attempting to have Sweave write files to a different directory
> via:
> 
> testfile <- system.file("Sweave", "Sweave-test-1.Rnw",
>                         package = "tools")
> 
> ## create a LaTeX file
> Sweave(
>       testfile,
>       output = "C:/temp/Sweave-test-1.tex",
>       stylepath = FALSE
>       )
> 
> but it places the graphics files in the working directory.

I guess the simplest workaround is to change the working directory
before you call Sweave(), i.e.
  setwd("C:/temp/")
  Sweave(testfile, output = "myfile.tex", stylepath = FALSE)
 
> Does anyone have any ideas on getting all of the files in one place
> (automatically)? The include option says:
> 
> include: logical (TRUE), indicating whether input statements for text
> output and includegraphics statements for figures should be
> auto-generated. Use include=FALSE if the output should appear in a
> different place than the code chunk (by placing the input line
> manually).

This is about the 
  \includegraphics{}
statement within the TeX file. Of course you can set each one of these
explicitely giving the full path to the graphics file, but I guess this
is rather cumbersome.

> If this is the solution, the default value should already be resolving
> it(correct?). I'd try setting it to FALSE, but it's not clear how to
> call this option.

You need to do that in the .Rnw file, e.g.

<<fig = TRUE, include = FALSE>>=
plot(1:10)
@
 
hth
Z

> Thanks in advance,
> 
> Max
> 
> 
> 
> 
> **********************************************************************
> This message is intended only for the designated
> recipient(s...{{dropped}}
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list