From smyth at wehi.edu.au  Mon Jan 17 05:53:52 2005
From: smyth at wehi.edu.au (Gordon Smyth)
Date: Mon Jan 17 05:54:09 2005
Subject: [Rd] running Sweave from Windows XP Explorer
In-Reply-To: <Pine.LNX.4.61.0501161445240.6370@gannet.stats>
References: <4717.220.236.48.36.1105851224.squirrel@220.236.48.36>
	<41EA799E.6080501@statistik.uni-dortmund.de>
	<Pine.LNX.4.61.0501161445240.6370@gannet.stats>
Message-ID: <6.2.0.14.1.20050117154656.0227ed38@imaphost.wehi.edu.au>

At 02:02 AM 17/01/2005, Prof Brian Ripley wrote:
>On Sun, 16 Jan 2005, Uwe Ligges wrote:
>>Gordon K Smyth wrote:
>
>>>I'd like to create a suitable batch file or shortcut so that I can run 
>>>Sweave on a .Rnw or .Rtex file simply by clicking on the file from 
>>>Windows Explorer in Windows XP (as I do with latex, bibtex etc).  This 
>>>looks tantalisingly possible using R CMD BATCH or Rterm possibly in 
>>>combination with a .bat file.  Has anyone succeeded is setting it up and 
>>>would give me a pointer?
>
>>As a very simple starting *idea*, a batch file could look like, e.g.,
>>
>>  R CMD BATCH --no-save c:/myscripts/MakeSweave.R
>>  texi2dvi --pdf %1.tex
>>  gsview32 %1.pdf
>>
>>
>>with MakeSweave.R:
>>
>>  library(tools)
>>  for(i in list.files(pattern = "\\.Rnw$")) Sweave(i)
>
>Another idea would be
>
>rterm --no-save --args "%1" < c:/myscripts/MakeSweave.R > "%1.log"
>
>where MakeSweave.R was
>
>library(tools)
>args <- commandArgs()
>inp <- args[length(args)]
>Sweave(inp)
>base <- sub("\.(Rnw|Rtex)$", "", inp)
>texi2dvi(paste("base", ".tex", sep=""), pdf=TRUE)
>shell.exec(paste("base", ".pdf", sep=""))
>
>Worked for me (in R-devel) on the example in utils/Sweave.

Works for me too. Very nice. Thanks to you both.

Gordon

>--
>Brian D. Ripley,                  ripley@stats.ox.ac.uk
>Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
>University of Oxford,             Tel:  +44 1865 272861 (self)
>1 South Parks Road,                     +44 1865 272866 (PA)
>Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] running Sweave from Windows XP Explorer
Gordon Smyth