[R] Comments in read.table

Prof Brian Ripley
2000-11-24T13:53:06Z

> Date: Fri, 24 Nov 2000 14:46:47 +0100
> From: LAM <Lemine-Mohamed.Ould-Mohamed-Abdallahi at imag.fr>
> To: "r-help at stat.math.ethz.ch" <r-help at
stat.math.ethz.ch>
> Subject: [R] Comments in read.table
>
> I know it is possible to use the character "#" to comment lines
in
> script files.

R-language file, yes

>
> Is it possible to give an argument (just like skip) to the fuction
> read.table to avoid reading commented lines in data files.

No.

> I want to use this function to read a table in a data file like this
> #-------------------------------
> x y z
> #my data begin here
> 1 2 3
> 12 3 4
> 1 0 1
> # no comment !!!
> 2 3 5
> #--------------------------------

Pre-process them with e.g. Perl to remove the comment lines, or
even with R itself (read in the lines, remove those starting with #,
write them out to a temp file and call read.table on the temp file).

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