[Rd] Sweave wish items

Gabor Grothendieck ggrothendieck at gmail.com
Thu Oct 18 17:04:36 CEST 2007


A scanario I have is spawning a Sweave job from another program (not
necessarily written in R).  That program needs to pass some information
to the Sweave program including what the file name is of the report to
produce.

Currently it calls a shell script which calls R CMD Sweave but it would
be nice if R CMD Sweave were powerful enough to do that itself.  These
are the features that would be desirable:

- support --args or some other method of passing arguments from
  R CMD Sweave line to the Sweave script

- have a facility whereby R CMD Sweave can directly generate the
.pdf file and an argument which allows the caller to define the name
of the resulting pdf file. e.g. --pdf

- -o or some way to define the name of the output file.  I need to
have many different outputs from the same Rnw file so its
important to name them differently.

- an -x argument similar to Perl/Python/Ruby such that if one calls
R CMD Sweave -x abc myfile.Rnw then all lines up to the first one
matching the indicated regexp are skipped.  This facilitates combining
the script with a shell or batch file if the previous is not enough.

Thus one could spawn this from their program:

R CMD Sweave --pdf myfile.Rnw -o myfile-123.pdf --args 23

and it would generate a pdf file from myfile.Rnw of the indicated
ame passing 23 as arg1 to the R code embedded in the Sweave file.

Also it would be possible to place Windows batch commands and
the Sweave file in the same file and the batch commands would
look like this:

-----------------------------
... various Windows batch commands ...
R CMD Sweave -x "^.EOF" --pdf -o %1 %0 --args %2
.... maybe more commands ....
exit
% EOF
... Sweave code goes here ...



More information about the R-devel mailing list