[R] Sweave problem

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Feb 5 08:44:57 CET 2004


Note that ?scan says

    file: the name of a file to read data values from.  If the
          specified file is '""', then input is taken from the keyboard

and you want it to come from the file.  So I would not have expected it to 
work.

However, the help file is not totally accurate, as this will work in a
batch file in R (although it has not worked in some versions of S-PLUS).  
The problem is that Sweave does expect the input to all be S code, and
does not get as far as running it.


Far from being `rather simple', this is a rather sophisticated usage, 
intended for use only at a keyboard.


On Thu, 5 Feb 2004, Murray Jorgensen wrote:

> Here is the file minimal.Snw:
> 
> \documentclass[a4paper]{article}
> \title{R tips and tricks}
> \author{Murray Jorgensen}
> \usepackage{Sweave}
> \begin{document}
> \maketitle
> \section*{Entering data from a single variable}
> The following data are transformed tensile strength measurements on 
> polyester
> fibres. They may be found on the file \texttt{TENSILE.DAT}. We
> may enter this data into R using the \texttt{scan} command.
> <<>>=
> strength <- scan()
> 0.023   0.032   0.054   0.069   0.081   0.094
> 0.105   0.127   0.148   0.169   0.188   0.216
> 
> @
> \end{document}
> 
> and now I attempt to use SWeave to convert it to minimal.tex:
> 
>  > Sweave("minimal.Snw")
> Writing to file minimal.tex
> Processing code chunks ...
>   1 : echo term verbatim
> 
> Error:  chunk 1
> Error in parse(file, n, text, prompt) : parse error
> 
> It seems a rather simple piece of code to generate such an error message!
> 
> Murray
> 
> [R 1.8.1 on Windows XP]
> 

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list