From ripley@stats.ox.ac.uk  Thu Aug  8 13:33:30 2002
From: ripley@stats.ox.ac.uk (ripley@stats.ox.ac.uk)
Date: Thu, 8 Aug 2002 13:33:30 +0100 (BST)
Subject: read.table ignores first 5 lines (PR#1885)
In-Reply-To: <51F9C42DA15CD311BD220008C707D81906FFC55F@usrymx10.merck.com>
Message-ID: <Pine.LNX.4.31.0208081316200.28285-100000@gannet.stats>

On Thu, 8 Aug 2002, Liaw, Andy wrote:

> Prof. Ripley,
>
> In that case, is it possible to check for such things and give an error in
> read.table?  (Or perhaps warn against such misuse in the help file...)

It is now warned about in the help file.

It's impossible to give a warning, as it is scan behaving differently
in one particular case, not going through the connections machinery so it
can give prompts.  On the other hand, at R level we don't know what
stdin() is.

The only way I see to fix this is inside scan().  That might be possible,
On the other hand, there really are easy workarounds if all the input is
available: just use readLines to a character vector and call read.table on
the result.

> read.table(textConnection(readLines()), header=T)
>  a b c
> 1 2 3
> 4 5 6
> 7 8 9
> 10 11 12
> 13 14 15
> 16 17 18
> 19 20 21
> 22 23 24
>
>    a  b  c
1  1  2  3
2  4  5  6
3  7  8  9
4 10 11 12
5 13 14 15
6 16 17 18
7 19 20 21
8 22 23 24

where I pasted in the first block (with the > prompts).  Rgui won't work
with this, though, another way in which stdin() is special.

-- 
Brian D. Ripley,                  ripley@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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


read.table ignores first 5 lines (PR#1885)
ripley@stats.ox.ac.uk