[R] read.table error

Peter Ehlers ehlers at ucalgary.ca
Sat Jun 20 00:32:26 CEST 2009


I'm guessing that there's something wrong with one
of your column separators. Have you tried leaving out
the 'sep="\t"' argument?

  -P

Forafo San wrote:
> Hello,
> 
> I'm receiving an error on attempting to use the read.table() function
> to read in data from a tab-delimited file. The file has more than
> 60,000 rows with 94 tab-delimited columns. However, the error occurs
> on row 3 of the file:
> 
>> wl <-read.table("sr003lines.tab", header=T, sep="\t")
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  :
>   line 3 did not have 94 elements
> 
> On receiving this error, I wrote a python script to go through the
> file to find rows with fewer than the 94 columns -- python finds that
> the first row with fewer than 94 columns is 1,706 -- much later than
> what R reports.  R keeps running into this problem even with my
> python-massaged input file that I know for sure contains only rows
> with 94 columns.
> 
> I also copied the first 4 rows of the input file into a separate file
> -- R isn't able to get past this problem.  I examined the row (line 3)
> of the input file -- the only thing that's unique about this line is
> that it contains a long string (236 characters) in a column that in
> the previous rows was empty.  Any chance that this sort of thing would
> cause R to run into a road block?
> 
> Thanks,
> Premal P. Vora
> Associate Prof. Finance
> Penn State Harrisburg
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
>




More information about the R-help mailing list