Re: [R] Problem with Sweave

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Tue, 15 May 2007 21:31:39 -0400

On 15/05/2007 9:22 PM, Thomas Adams wrote:
> I am using R 2.5 on a Linux Redhat platform. I can successfully run some
> example *.Rnw files through Sweave and generate pdf files. When I try my
> own example file, "test.Rnw":
>
> \documentclass[a4paper]{article}
> \title{Test Sweave Example}
> \author{Thomas Adams}
> \begin{document}
> \maketitle
> In this example we embed parts of the examples from the
> \texttt{boxplot} and \texttt{lattice} figures into a \LaTeX{} document
> <<>>=
> library(verification)
> library(lattice)
> dat<-read.table("verification_summary_20051024_table.txt",sep="\t",header=TRUE)
> \begin{center}
> <<fig=TRUE,echo=FALSE>>=
> boxplot(dat$MAE ~ dat$BASINID)
> abline(h=1)
> abline(h=0.5,col="red")
> @
> \end{center}
> \end{document}
>
>
> I get the following error:
>
> xt4-tir:adams> echo 'Sweave("test.Rnw")' | R --vanilla --quiet
> > Sweave("test.Rnw")
> Writing to file test.tex
> Processing code chunks ...
> 1 : echo term verbatim
>
> Error: chunk 1
> Error in parse(file, n, text, prompt, srcfile, encoding) :
> syntax error, unexpected $undefined in:
> "
> "
> Execution halted
>
> I really do not know where to begin to decipher the error messages. Any
> suggestions?

You didn't end the first code chunk (no @ at the end). This isn't obvious from the error message, but it is obvious if you run Stangle, and look at the resulting R file, because you know the error is in chunk   1, and that last line of it doesn't look much like R code:

###################################################
### chunk number 1:
###################################################
library(verification)
library(lattice)
dat<-read.table("verification_summary_20051024_table.txt",sep="\t",header=TRUE) \begin{center}
###################################################
### chunk number 2:
###################################################
boxplot(dat$MAE ~ dat$BASINID)
abline(h=1)
abline(h=0.5,col="red")

Duncan Murdoch



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 and provide commented, minimal, self-contained, reproducible code. Received on Wed 16 May 2007 - 01:36:37 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 16 May 2007 - 02:31:46 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.