[R] How to set directory Rscript runs in/Sweave output directory

From: <Paul.Rustomji_at_csiro.au>
Date: Mon, 28 Jul 2008 16:08:58 +1000


I am using Sweave to generate some pdf reports using R on a Windows platform and would like to control the output directory that the generated .tex file goes to. Basically I use the following commands in a batch file:

set outdir=c:/output/1234

Rscript -e Sweave('C:/pathpathpath/script.Rnw')

Which produces script.tex

Sweave has the option of specifying an output directory for figures, but the .tex file is always created in the directory that the Rscript command was initiated in via the batch file. So my questions are thus:

  1. Can Rscript be invoked in a nominated directory (ie %outdir%) from within a batchfile
  2. Or Can Sweave direct the .tex output file to a nominated directory?

I have tried Rscript -e setwd(shell('echo %outdir%',intern=T)) -e Sweave(....

to change the current working directory to %outdir% before invoking Sweave but this doesn't seem to work in batch mode.


Paul Rustomji
Rivers and Estuaries
CSIRO Land and Water
GPO Box 1666
Canberra ACT 2601

ph +61 2 6246 5810
mobile 0406 375 739

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. Received on Mon 28 Jul 2008 - 06:11:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 28 Jul 2008 - 07:33:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive