[R] package Utils Sweave Example Error

Duncan Murdoch murdoch at stats.uwo.ca
Thu Oct 16 20:17:20 CEST 2008


On 10/16/2008 12:19 PM, Felipe Carrillo wrote:
> This is my sessionInfo() and Sys.getenv("PATH") 
> 
>   library(tools)
> testfile <- system.file("Sweave", "Sweave-test-1.Rnw", package = "utils")
> ## enforce par(ask=FALSE)
> options(device.ask.default=FALSE)
> ## create a LaTeX file
> Sweave(testfile)
> Writing to file Sweave-test-1.tex
> Processing code chunks ...
>  1 : print term verbatim
>  2 : term hide
>  3 : echo print term verbatim
>  4 : term verbatim
>  5 : echo term verbatim
>  6 : echo term verbatim eps pdf
>  7 : echo term verbatim eps pdf
> 
> You can now run LaTeX on 'Sweave-test-1.tex'
> ## This can be compiled to PDF by
> texi2dvi("Sweave-test-1.tex", pdf=TRUE,quiet=FALSE)
> 
> This is pdfTeX, Version 3.1415926-1.40.9 (MiKTeX 2.7)
> entering extended mode
> ("C:/Program Files/R/R-2.7.2/bin/Sweave-test-1.tex"
> LaTeX2e <2005/12/01>
> Babel <v3.8l> and hyphenation patterns for english, dumylang, nohyphenation, ge
> rman, ngerman, german-x-2008-06-18, ngerman-x-2008-06-18, french, loaded.
> ("C:\Program Files\MiKTeX 2.7\tex\latex\base\article.cls"
> Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
> ("C:\Program Files\MiKTeX 2.7\tex\latex\base\size10.clo"))
> ("C:\Program Files\MiKTeX 2.7\tex\latex\ltxmisc\a4wide.sty"
> ("C:\Program Files\MiKTeX 2.7\tex\latex\ntgclass\a4.sty"))
> ! Missing \endcsname inserted.
> <to be read again> 
>                    \protect 
> l.11 \begin
>            {document}
> ? pdflatex.EXE: Bad file descriptor


This appears to be the problem.  I'm not certain, but I would guess if 
you look in the "C:/Program Files/R/R-2.7.2/bin/Sweave-test-1.tex" file 
you'll see a line something like this:

\usepackage{C:/Program Files/R/R-2.7.2/share/texmf/Sweave}

That line (which was added by Sweave) will not work, because LaTeX does 
not understand blanks in file paths.  There are a couple of workarounds:

1.  Install R in a directory that doesn't contain blanks.

2.  Include \usepackage{Sweave} in the Rnw file you're processing; this 
will stop Sweave from adding anything.  I believe we set things up so 
that MikTeX will find it in the right place (though I don't normally use 
texi2dvi, so I'm not sure).

To test this, you can just go and edit the Sweave-test-1.tex file now, 
replacing the long line with the short version.

Duncan Murdoch

> texify: pdflatex failed for some reason (see log file).
> Error in texi2dvi("Sweave-test-1.tex", pdf = TRUE, quiet = FALSE) : 
>   running 'texi2dvi' on 'Sweave-test-1.tex' failed
> 
> sessionInfo()
> R version 2.7.2 (2008-08-25) 
> i386-pc-mingw32 
> 
> locale:
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
> 
> attached base packages:
> [1] tools     stats     graphics  grDevices utils     datasets  methods   base     
>> Sys.getenv("PATH") 
> PATH
> "C:\\Program Files\\MiKTeX 2.7\\miktex\\bin;C:\\GTK\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\Program Files\\SYSTAT 10\\;C:\\Program Files\\SYSTAT 10\\XGRAPH\\;C:\\Program Files\\Wave Systems Corp\\Dell Preboot Manager\\Access Client\\v5\\;C:\\Program Files\\ATI Technologies\\ATI.ACE\\Core-Static;c:\\Program Files\\Microsoft SQL Server\\90\\Tools\\binn\\"
> 
> Thank you
> 
> Felipe D. Carrillo  
> Supervisory Fishery Biologist  
> Department of the Interior  
> US Fish & Wildlife Service  
> California, USA
> 
> 
> --- On Thu, 10/16/08, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
> 
>> Try running it as texi2dvi("Sweave-test-1.tex",
>> pdf=TRUE, quiet=FALSE), 
>> and post the list of error messages.
>> 
>> You should also show us the results of sessionInfo() and 
>> Sys.getenv("PATH"), and tell us which version of
>> LaTeX you have installed.
>> 
>> Duncan Murdoch
>> > 
>> > ______________________________________________
>> > R-help at r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained,
>> reproducible code.
> 
> 
>



More information about the R-help mailing list