[R] read.table problem

Peter Dalgaard p.dalgaard at biostat.ku.dk
Wed Jan 25 09:56:23 CET 2006


Andrej Kastrin <andrej.kastrin at siol.net> writes:

> Dear R useRs,
> 
> I have big (23000 rows), vertical bar delimited file:
> 
> e.g.
> A00001|Text a,Text b, Text c|345
> A00002|Text bla|456
> ...
> ..
> .
> 
> Try using
> 
> A <- read.table('filename.txt', header=FALSE,sep='\|')
>  
> process stop at line 11975 with warning message:
> number of items read is not a multiple of the number of columns
> 
> I have no problems with processing similar file, which is only 10000 
> rows long?
> 
> Any suggestion what's the problem here. Thank's in advance.

Well, the most obvious suspect is the file...

You might try 

table(count.fields('filename.txt',sep='|'))

(There's no point in escaping the vertical bar) 

Also, beware of quote symbols in the file, and possibly consider using
fill=TRUE.

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907




More information about the R-help mailing list