[R] read.table error

Forafo San ppv.grps at gmail.com
Fri Jun 19 23:50:14 CEST 2009


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




More information about the R-help mailing list