[R] read.table error

Forafo San ppv.grps at gmail.com
Sun Jun 21 21:25:55 CEST 2009


Thank-you all for your reply.  It turns out that there were both #
characters and unbalanced quotes in the character fields that were
creating problems for read.table.

Putting in the options quote=""  and comment="" in the read.table
statment fixes the problem.


On Fri, Jun 19, 2009 at 9:51 PM, jim holtman<jholtman at gmail.com> wrote:
> Try  comment.char='', quote=''
>
> You may have unbalanced quotes or comments (#) in your data.
>
> On Fri, Jun 19, 2009 at 5:50 PM, Forafo San <ppv.grps at gmail.com> 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.
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>




More information about the R-help mailing list