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

Gabor Grothendieck ggrothendieck at myway.com
Sun Feb 27 13:32:44 CET 2005


Gorjanc Gregor <Gregor.Gorjanc <at> bfro.uni-lj.si> writes:

: 
: Gabor,
: 
: can you say this in some other way. I appologize, but I just don't 
: understand anything. I really don't see any connection with R CMD CHECK
: and vignettes.

Vignettes are pdf documentation files written in Sweave which accompany some
packages.   The 'zoo' package is an example of one which has a vignette.
Try 
   vignette() 
to see a list of vignettes on your system or 
   library(zoo)
   vignette("zoo")
to see the zoo vignette.

A package must pass R CMD CHECK to be accepted on CRAN.  Also, even if
a package is not destined for CRAN its a good idea to make sure one's 
packages pass R CMD CHECK.   The availability of this tool is very helpful 
in improving the quality of one's software.  One of the
things R CMD CHECK does is to test the vignette build to ensure that there 
are no errors.  By doing the include at the latex, rather than the Sweave, 
level one has the possibility of preprocessing portions of the Sweave 
file before R CMD CHECK is run and that could be desirable in the 
two situations I mentioned.   A third reason is to provide upward
compatibility with the way it works now.

: 
: I would just like to see that Sweave would follow \input of \include
: commands of LaTeX. You can try with the following example bellow. I
: don't know how Sweave is parsing Rnw files, but my idea was that if 
: Sweave finds \input or \include in a "top" file (a.Rnw) it would also
: parse "included" file (a1.Rnw) and then contninue with the top file
: (a.Rnw). As I said just an idea. All this would be done at Sweave
: level and one should run LaTeX only after Sweave handles all the files.

Since this might not be desirable in all instances,
if Sweave were to have an include facility then it should
not be implemented in such a way that the latex include facility
can no longer be used.  The point was just that it should be possible 
to do the include at the Sweave or at the latex level.  

: 
: Thanks, Gregor
: 
: -----------------------------------------------------------------------
: If this were supported it should have a different command than the
: latex one or else one would not be able to do it at the latex level.
: One might want to do it at the latex level rather than the Sweave
: level in the case that one wants to have a vignette pass R CMD CHECK
: but the vignette depends on software that is not generally available
: or perhaps the vignette involves a large computation which would
: otherwise impact every run of R CMD CHECK.  In these cases the portion
: of the vignette that depends on the unavailable software or large
: computation could be preprocessed using Sweave and then included
: at the latex level to get by R CMD CHECK.
: 
: Gorjanc Gregor <Gregor.Gorjanc <at> bfro.uni-lj.si> writes:
: 
: :
: : Imagine this situation:
: :
: : % --- a.Rnw start ---
: : \documentclass{book}
: : \usepackage{Sweave}
: : \begin{document}
: : % some toy example
: : <<print=TRUE>>=
: : x <- 1:10
: :  <at>
: : % now we input additional file
: : \input{a1}
: : % and lets look again at x
: : <<print=TRUE>>=
: : x
: :  <at>
: : \end{document}
: : % --- a.Rnw end ---
: :
: : % --- a1.Rnw start ---
: : %\usepackage{Sweave}
: : % add 1 to x
: : <<print=TRUE>>=
: : x <- x + 1
: :  <at>
: : % --- a1.Rnw end ---
: :
: : > Sweave("a.Rnw")
: : Writing to file a.tex
: : Processing code chunks ...
: :  1 : echo print term verbatim
: :  2 : echo print term verbatim
: :
: : You can now run LaTeX on a.tex
: :
: : When you run Sweave on a.Rnw it founds only two chunks of R code. So it
: : does not go into a1.Rnw i.e. it does not follow \input command. This
: : would be very usefull if one has such hierarchies in documents. Afcourse
: : one can use Sweave on a.Rnw and a1.Rnw and then run LaTeX, but it would be
: : nice if just one Sweave would do Sweave job for all files i.e. the same
: : as LaTeX does.
: 
: --
: Lep pozdrav / With regards,
:     Gregor GORJANC
: 
: ------------------------------------------------------------------------
: University of Ljubljana
: Biotechnical Faculty       URI: http://www.bfro.uni-lj.si/MR/ggorjan
: Zootechnical Department    email: gregor.gorjanc <at> bfro.uni-lj.si
: Groblje 3                  tel: +386 (0)1 72 17 861
: SI-1230 Domzale            fax: +386 (0)1 72 17 888
: Slovenia
: 
: ______________________________________________
: R-help <at> stat.math.ethz.ch mailing list
: https://stat.ethz.ch/mailman/listinfo/r-help
: PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
: 
:




More information about the R-help mailing list