[Rd] Sweave.sh shell script on CRAN

Duncan Murdoch murdoch at stats.uwo.ca
Mon Apr 16 16:02:23 CEST 2007


On 4/16/2007 7:53 AM, Gregor Gorjanc wrote:
> Duncan Murdoch wrote:
>>> I do not have any experience with use of (bash) shell scripts under
>>> Windows. Sweave.sh can be used with Cygwin, but I am not sure how to use
>>> shell script without Cygwin. I noticed that some "scripts" in R*/bin
>>> directory on our Windows machine are perl (build, check, INSTALL, ...)
>>> and shell (Rd2dvi.sh, Stangle.sh, Sweave.sh, ...) scripts. This
>>> therefore means that R ships also perl and shell interpreter or am I
>>> missing something?
>> 
>> We don't ship Perl or sh.exe, but we do describe how to get them in the
>> R Admin manual.
> 
> Maybe I got this totally wrong. Say someone who uses Windows finds R and
> installs it via setup file. Can he/she launch the folowing without
> having Perl and/or sh.exe?
> 
> R CMD script whateverOption

No.  Installing a binary package has a pure R implementation so it 
doesn't need R CMD, but most of the capabilities of R CMD are not 
available with a basic R install.

There are two reasons for this.  One is that the extra tools that are 
needed take up a lot of space, so they would make the setup file really 
huge.  That's an issue of less importance these days than in the past.

Another issue that is still important is that not all the tools needed 
have licenses compatible with redistribution:  in particular ActiveState 
Perl and the Microsoft Help Workshop.  There are other Perl 
implementations, but in the past Brian Ripley found that they didn't 
work.  I don't know if that's still true.  (In fact, I don't know if the 
licenses still limit redistribution.)

>> I'd be interested in talking to you about integration of my patchDVI
>> functions into your script.  They allow forward and reverse search
>> between the .dvi file and the .Rnw file (in yap and xdvi, at least).
> 
> I am all ears.

The package is on my web page as

http://www.stats.uwo.ca/faculty/murdoch/software/patchDVI_1.0.tar.gz

Starting in R 2.5.0 (currently in beta), if you use Sweave options including

\SweaveOpts{keep.source=TRUE,concordance=TRUE}

then it will write out an \input{} for a file containing a TeX 
\special{} encoding the concordance between the lines in the .Rnw file 
and the lines in the .tex file.  The patchDVI package contains routines 
to look through a .dvi file for these specials, and the specials 
inserted by latex when you ask for forward and reverse search (the 
--src  option in MikTeX, not sure how it's invoked in other 
implementations), and patches the .dvi so the references point to the 
.Rnw file instead.

It would make more sense for the previewer to interpret the specials 
directly and so not require the patch, but currently it appears nobody 
has done something like this.  (If you know differently, please let me 
know!)  I think most people don't use forward and reverse search, so 
there's not a lot of pressure for this feature in the previewers.

It would probably also make sense to make the concordance format a 
little more general than it currently is (it assumes that each .tex file 
comes from exactly one source Rnw file, for instance; I think that's 
generally true now, but not necessarily true about other preprocessors.).

In the current implementation, this means the processing goes like this:

1.  Run Sweave to produce the .tex.
2.  Run latex to produce the .dvi.
3.  Run patchDVI to patch the .dvi.
4.  Run the previewer.

Since invoking R is slow in Windows, I wrote an R function SweaveMiktex 
in patchDVI that does steps 1-3 in one R session.

Duncan Murdoch



More information about the R-devel mailing list