[R] Comments in read.table

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Nov 24 14:53:06 CET 2000


> 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

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list