[R] Importing with read.table

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Wed Nov 13 22:41:31 CET 2002


There _are_ three columns: | is the column _separator_.  So give three
column names and ignore/discard the third column.

Alternatively preprocess the file to remove the incorrect (according to
your description) second separator. On Unix piping though sed will do it,
and there are lots of other ways.

On Wed, 13 Nov 2002, Balint, Jess wrote:

> Hi all. I have something similar to the following:
>
> myinfo <- read.table( file = "myfile.txt", sep = "|", col.name = c( "data1",
> "data2" ) )
>
> myfile.txt:
> a|1|
> b|2|
>
> However, since there are two pipe (|) characters, it reads it in and thinks
> there should be three columns. This is not the case and I get a warning
> about col.names is wrong length. Is there a way around this? Thanks.


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