Its highly unusual to use xls as the extension for a text file.
Use something more suggestive.

print out the line in question.  For example, note that scan
and read.table have different defaults for the comment character,
namely, none and #.

On Mon, Sep 21, 2009 at 10:23 PM, Peng Yu <pengyu...@gmail.com> wrote:
> On Mon, Sep 21, 2009 at 9:12 PM, Peng Yu <pengyu...@gmail.com> wrote:
>> Hi,
>>
>> I have the following commands. It says line 5205 does not have 22
>> elements. But I use my 'vim' checked that line in the file. It has 22
>> fields. Can somebody let me know how to further debug this case?
>>
>> Regards,
>> Peng
>>
>>> annotation = read.table("../EC_results/Juan_15wks_gene_core.xls", header=T, 
>>> sep='\t',quote='')
>> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  :
>>  line 5204 did not have 22 elements
>>> annotation = count.fields("../EC_results/Juan_15wks_gene_core.xls", 
>>> sep='\t',quote='')
>>> which(annotation!=22)
>> [1] 5205
>>
>
>
> I also run the following command to test, which confirms that line
> 5205 has 22 elements. Is it a bug in read.table?
>
>> scanned_file = scan("../EC_results/Juan_15wks_gene_core.xls", 
>> what=character(),sep='\n',quote='')
> Read 23333 items
>> length(strsplit(scanned_file[5205],'\t')[[1]])
> [1] 22
>
> Regards,
> Peng
>
> ______________________________________________
> R-help@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.
>

______________________________________________
R-help@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.

Reply via email to