[R] Sweave and \input or \include LaTeX commands

Friedrich.Leisch@tuwien.ac.at Friedrich.Leisch at tuwien.ac.at
Tue Mar 1 14:07:09 CET 2005


>>>>> On Tue, 1 Mar 2005 12:08:25 +0000 (UTC),
>>>>> Gabor Grothendieck (GG) wrote:

  >  <Friedrich.Leisch <at> tuwien.ac.at> writes:
  >> I currently also plan only a \SweaveInput{}, 

  > I agree that its clearer to keep the two systems distinct rather
  > than having subtle changes in functionality depending on the
  > extension of the file in \input.

  > While we are discussing I just wanted to bring two related points up
  > regarding how Sweave and R CMD interact.

  > 1. As mentioned in a previous post in this thread, if I don't
  > want R CMD CHECK to process a certain portion of my vignette 
  > (since its involves lengthy processing or software that might not
  > be available on other systems) I place that portion into a file 
  > called sub, say, with no extension so that R CMD CHECK does not know 
  > its a Sweave file (and therefore automatically process it).  I then 
  > process it manually with Sweave:  Sweave("sub") and in my main file, 
  > main.Rnw, have an input statement

  > \input{sub.tex}

  > The only thing that's a bit confusing is that sub has no extension
  > but otherwise this has the intended effect of letting me circumvent
  > the R CMD CHECK for sub.   This is all ok, it works fine, but I 
  > was just wondering if there are any clearer ways of achieving this
  > effect.  I guess I could use an extension such as .Rnw-hide or
  > use the .Rbuildignore file to mask it (although using .Rbuildignore
  > in that way has the disadvantage that it would be entirely excluded 
  > from the build) but was just wondering if there is some standard way 
  > of dealing with this situation.

Both R and TeX are programming languages, and both feature if/else
statements, so you can easily do

if(FAST){
  load("pre-computed-results.RData")
}
else{
  res = compute.results()
  save(res, file="pre-computed-results.RData")
}

But note that vignettes are meant as introductionary material
containing user-runnable examples, so putting lengthy computations in
there might not serve that purpose too well (depends on the packages
and application, of course).


  > 2. A second problem that is related is that I think there should
  > be an easy way to include a .pdf vignette that was not generated
  > by Sweave or even latex.  Currently, as I under it, one must use 
  > Sweave since the package building process uses the \VignetteIndexEntry 
  > and associated commands to know how to process the build.  If this
  > is already possible then can someone indicate how its done.  Some
  > time ago I raised this point but no one responded at that time.


Packages already can have documentation in arbitrary formats (although
we strongly recommend PDF) in the inst/doc directory and many packages
on CRAN do have non-Sweave docs.  The directory is linked into the
help.start() version of the help system ("HTML help" in the Windows
Help menu). If inst/doc contains a file index.html that is used as a
TOC for the package docs. I decided to call those other documentation
objects "user guides" mostly because I had no better idea.

I think we should not call them vignettes for several reasons.  Users
should be able to expect that they can easily get and execute the code
contained in a "vignette". r-devel contains a poor man's non-gui
version of Bioconductor's vExplorer() where the edit() method for
vignette objects opens the code in an editor. It would be absolutely
fine with me to use alternative methods for vignettes than Sweave (I
am unlikely to implement any ;-), but code extraction for testing and
learning is a key concept.

So a PDF file at the moment does not qualify as a vignette, and that
is not because of missing \VignetteIndexEntry{} statements, but
because you cannot extract the code from the file. The vignette
concept of documents where you can do computations on the code
contained in the document is by no means limited to Sweave, but
currently we do not have any other implementation which can be
installed on all key platforms without too much difficulty.


BTW, I think this discussion is getting way too technical for the
r-help list -> if this thread goes on it should do so on r-devel.

Best,

-- 
-------------------------------------------------------------------
                        Friedrich Leisch 
Institut für Statistik                     Tel: (+43 1) 58801 10715
Technische Universität Wien                Fax: (+43 1) 58801 10798
Wiedner Hauptstraße 8-10/1071
A-1040 Wien, Austria             http://www.ci.tuwien.ac.at/~leisch




More information about the R-help mailing list