Skip to content
Prev 24662 / 63424 Next

Sweave.sh shell script on CRAN

On 4/16/2007 7:53 AM, Gregor Gorjanc wrote:
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.)
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