[R] Sweave problem

Murray Jorgensen maj at stats.waikato.ac.nz
Thu Feb 5 08:57:57 CET 2004


Sorry, in an effort to be minimal I cut away some of my surrounding text:
The first code block is meant to be typed in by the user, except for the
numbers which are to be thought of as pasted in. I certainly do not wish to
supply a file name to scan() for this particular example.

Murray

At 07:44 5/02/2004 +0000, Prof Brian Ripley wrote:
>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
> 
Dr Murray Jorgensen      http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: maj at waikato.ac.nz                                Fax 7 838 4155
Phone  +64 7 838 4773 wk    +64 7 849 6486 home    Mobile 021 1395 862




More information about the R-help mailing list