From ripley@stats.ox.ac.uk  Wed Sep 12 18:18:10 2001
From: ripley@stats.ox.ac.uk (Prof Brian D Ripley)
Date: Wed, 12 Sep 2001 18:18:10 +0100 (BST)
Subject: [Rd] feature request: comment character in read.table?
In-Reply-To: <Pine.LNX.4.30.0109121221400.1270-100000@bolker.zoo.ufl.edu>
Message-ID: <Pine.GSO.4.31.0109121814450.6636-100000@auk.stats>

On Wed, 12 Sep 2001, Ben Bolker wrote:

>
>   How difficult would it be (I could try myself if someone thought it
> would be straightforward) to change read.table to allow a comment
> character such as # or %?  My thought would be that anything on a line

It's hard in read.table, especially given the changes in R-devle to mke it
more flexible.  The place to do this seems to me to be the internals of
scan.  They are far from transparent, though.

> following a comment character would be ignored (so that the combination of
> blank.lines.skip=TRUE and a comment at the beginning of the line would
> lead to a line being skipped completely).
>  I'm always encouraging my students to comment their data sets, and it
> feels lame to tell them they have to count the number of initial lines in
> the data set in order to set the "skip" parameter appropriately.  (The
> comment character would also allow comments about a particular data
> point.)
>
>   I know I could hack this (a) with sed in Unix [but my students using
> Windows are likely to have trouble] (b) within R, by processing the file
> and creating a temporary file with comments deleted.  (b) is probably what
> I'll do as a temporary fix, but this seems to be a reasonable piece of
> functionality for R to have ...

(b) seems easy to me. Use either a file() connection or an output text
connection.  (I don't know if file(), that's no arg, works on Mac for
example, though.)

-- 
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] feature request: comment character in read.table?
Prof Brian D Ripley