Skip to content

problem with read.table

3 messages · ryszard.czerminski@pharma.novartis.com, Douglas Bates, Brian Ripley

#
Any ideas why read.table complains about not correct number of elements in 
line
while readLine/strsplit indicate that all lines have the same number of 
elements ?

R
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = 
dec,  : 
        line 32 did not have 27 elements
'\t')[[1]]) }
[1] 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 
27 27
[26] 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 
27 27
[51] 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27
[1] 0
[1] 27
#
ryszard.czerminski at pharma.novartis.com writes:
Try count.fields to see what line is giving problems.  Watch
especially for comment characters (default is '#') and quote
characters.  My good friends in Biological Sciences (including my
spouse and one of my children) have a habit of incorporating 3' and 5'
in descriptive text and that always trips me up.
#
On Tue, 3 Feb 2004 ryszard.czerminski at pharma.novartis.com wrote:

            
That is what count.fields is for.  Setting fill=TRUE in read.table can 
help detection, too.

One guess is that you have a comment character on that line, but one 
thing you did not show us is the appropriate lines of the file.