[R] Unexpected behaviour of read.table

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Sun May 30 23:59:20 CEST 1999


David Clayton <david.clayton at mrc-bsu.cam.ac.uk> writes:

> 1,,3
>  ,5,6
> ,8,9 
> 
> with 
> 
> read.table("test.dat", header=F, sep=",")
> 
> R gives an error:
> row.lens=
> [1] 3 3 2
> Error: all rows must have the same length.

Blimey! How did *that* go unnoticed for so long?? I think I've traced
it to the following section in do_countfields

	else if (sepchar) {
	    if (c == sepchar)
		nfields++;
	    else if (nfields == 0)
		nfields++;
	}

I don't think we want that 2nd 'else' there... 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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