[R] Latex error with Sweave example

From: sosman <sourceforge_at_metrak.com>
Date: Sat 06 Aug 2005 - 09:40:26 EST


I created a tex file following the example in the Sweave help which produced the following files in my working directory.

Sweave-test-1-006.eps
Sweave-test-1-006.pdf
Sweave-test-1-007.eps
Sweave-test-1-007.pdf
Sweave-test-1.tex

When I run latex on this, I get a latex error, log file below. I am running R 2.1.1 on Windows XP. I have installed "small MiKTeX" and I have added "C:\Program Files\R\rw2011\share\texmf" to the roots of MiKTex. The MiKTeX test ran fine after I installed it.

Any tips would be most appreciated.

This is e-TeX, Version 3.141592-2.2 (MiKTeX 2.4) (preloaded format=latex 2005.8.5) 6 AUG 2005 09:28
entering extended mode
**Sweave-test-1
(Sweave-test-1.tex
LaTeX2e <2003/12/01>
Babel <v3.8a> and hyphenation patterns for english, french, german, ngerman, du
mylang, nohyphenation, loaded.
(C:\usr\texmf\tex\latex\base\article.cls Document Class: article 2004/02/16 v1.4f Standard LaTeX document class (C:\usr\texmf\tex\latex\base\size10.clo
File: size10.clo 2004/02/16 v1.4f Standard LaTeX file (size option) )
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(C:\usr\texmf\tex\latex\ltxmisc\a4wide.sty Package: a4wide 1994/08/30

(C:\usr\texmf\tex\latex\ntgclass\a4.sty
Package: a4 1999/03/03 v1.2f A4 based page layout ))
! Missing \endcsname inserted.
<to be read again>

                    \protect
l.11 \begin
            {document}

?
! Emergency stop.
<to be read again>
                    \protect
l.11 \begin
            {document}

End of file on the terminal!

Here is how much of TeX's memory you used:   223 strings out of 95898
  2212 string characters out of 1195177
  46816 words of memory out of 1050593
  3336 multiletter control sequences out of 35000   3640 words of font info for 14 fonts, out of 500000 for 1000   14 hyphenation exceptions out of 607
  23i,0n,17p,117b,36s stack positions out of 1500i,500n,5000p,200000b,32768s No pages of output.

\documentclass[a4paper]{article}

\title{A Test File}
\author{Friedrich Leisch}

\usepackage{a4wide}

\usepackage{C:/PROGRA~1/R/rw2011/share/texmf/Sweave}
\begin{document}

\maketitle

A simple example that will run in any S engine: The integers from 1 to 10 are
\begin{Schunk}
\begin{Soutput}
 [1] 1 2 3 4 5 6 7 8 9 10
\end{Soutput}
\end{Schunk}

We can also emulate a simple calculator:
\begin{Schunk}
\begin{Sinput}
> 1 + 1
\end{Sinput}
\begin{Soutput}
[1] 2
\end{Soutput}
\begin{Sinput}

> 1 + pi
\end{Sinput}
\begin{Soutput}
[1] 4.141593
\end{Soutput}
\begin{Sinput}

> sin(pi/2)
\end{Sinput}
\begin{Soutput}
[1] 1
\end{Soutput}
\end{Schunk}

Now we look at Gaussian data:

\begin{Schunk}
\begin{Soutput}

 [1]  1.0549825921  1.0338743287  1.3960748544  0.8442504660 -1.3844903806
 [6] -0.1132289262  0.0340332855  0.0002775862 -1.0397650922  0.4255640780
[11] -0.0101131650 -0.9338368343 -0.8404841222  0.1815343256 -0.0655929025
[16] -0.6401327742  0.2787653149 -0.0940385332 -0.6531716561 -0.8501837369

\end{Soutput}
\begin{Soutput}

        One Sample t-test

data: x
t = -0.4006, df = 19, p-value = 0.6932
alternative hypothesis: true mean is not equal to 0 95 percent confidence interval:
 -0.4281708 0.2906027
sample estimates:
  mean of x
-0.06878406
\end{Soutput}
\end{Schunk}
Note that we can easily integrate some numbers into standard text: The third element of vector \texttt{x} is 1.39607485443702, the $p$-value of the test is 0.69319. % $

Now we look at a summary of the famous iris data set, and we want to see the commands in the code chunks. Note that the summary needs to be \texttt{print()}ed explicitly, because eval would discard it otherwise. I consider this a feature, because it allows for much finer control on what gets into the final report.

% the following code is R-specific, as data(iris) will not run in Splus. % Hence, we mark it as R code.
\begin{Schunk}
\begin{Sinput}
> data(iris)
> print(summary(iris))
\end{Sinput}
\begin{Soutput}
  Sepal.Length Sepal.Width Petal.Length Petal.Width

 Min.   :4.300   Min.   :2.000   Min.   :1.000   Min.   :0.100  
 1st Qu.:5.100   1st Qu.:2.800   1st Qu.:1.600   1st Qu.:0.300  
 Median :5.800   Median :3.000   Median :4.350   Median :1.300  
 Mean   :5.843   Mean   :3.057   Mean   :3.758   Mean   :1.199  
 3rd Qu.:6.400   3rd Qu.:3.300   3rd Qu.:5.100   3rd Qu.:1.800  
 Max.   :7.900   Max.   :4.400   Max.   :6.900   Max.   :2.500  
       Species  
 setosa    :50  

 versicolor:50
 virginica :50
\end{Soutput}
\end{Schunk}

\begin{figure}[htbp]

  \begin{center}
\begin{Schunk}
\begin{Sinput}
> library(graphics)
> pairs(iris)
\end{Sinput}
\end{Schunk}
\includegraphics{Sweave-test-1-006}

    \caption{Pairs plot of the iris data.}   \end{center}
\end{figure}

\begin{figure}[htbp]

  \begin{center}
\begin{Schunk}
\begin{Sinput}
> boxplot(Sepal.Length ~ Species, data = iris)
\end{Sinput}
\end{Schunk}
\includegraphics{Sweave-test-1-007}

    \caption{Boxplot of sepal length grouped by species.}   \end{center}
\end{figure}

% R is not S-PLUS, hence this chunk will be ignored:

\end{document}



R-help@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 Received on Sat Aug 06 09:45:25 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:44 EST