In an Sweave slide, I want to use sem::read.moments() and sem::specify.model(), which work by using scan() to read the following lines, up to the first blank line. However, Sweave
throws an error:

> Sweave("sem-thurstone.Rnw")
Writing to file sem-thurstone.tex
Processing code chunks ...
 1 : term hide (label=arrests-setup)
 2 : echo term hide (label=thurstone-data)

Error:  chunk 2 (label=thurstone-data)
Error in sem-thurstone.Rnw:43:12: unexpected numeric constant
42:     .828
43:     .776   .779
               ^

Is there some switch or option for Sweave that will make this work?
Below is the slide in question in an executable example:

\documentclass[dvipsnames,pdflatex,compress,beamer]{beamer}
\usepackage{Sweave}

\definecolor{Sinput}{rgb}{1,0,0}
\definecolor{Scode}{rgb}{0,0,0.56}
\definecolor{Soutput}{rgb}{0,0,1}
\DefineVerbatimEnvironment{Sinput}{Verbatim}{formatcom={\color{Sinput}},fontsize=\footnotesize,baselinestretch=0.9}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{formatcom={\color{Soutput}},fontsize=\footnotesize,baselinestretch=0.85}
\DefineVerbatimEnvironment{Scode}{Verbatim}{formatcom={\color{Scode}},fontsize=\small}

\begin{document}

\SweaveOpts{engine=R,height=6,width=6,results=hide,fig=FALSE,echo=TRUE}
\SweaveOpts{prefix.string=fig/sem}

\section{sem package: Second-order CFA, Thurstone data}

\begin{frame}[fragile]
  \frametitle{sem package: Second-order CFA, Thurstone data}
  \framesubtitle{Data}
Data on 9 ability variables:
<<thurstone-data, echo=TRUE>>=
R.thur <- read.moments(diag=FALSE, names=c('Sentences','Vocabulary',
   'Sent.Completion','First.Letters','4.Letter.Words','Suffixes',
   'Letter.Series','Pedigrees', 'Letter.Group'))
    .828
    .776   .779
    .439   .493    .46
    .432   .464    .425   .674
    .447   .489    .443   .59    .541
    .447   .432    .401   .381    .402   .288
    .541   .537    .534   .35    .367   .32   .555
    .38   .358    .359   .424    .446   .325   .598   .452

@
\end{frame}
\end{document}




--
Michael Friendly     Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    Web:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

______________________________________________
R-help@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.

Reply via email to