On Thu, 21 Jul 2005, Kristian Skrede Gleditsch wrote: > Dear all, > > I have encountered a strange problem with read.table().
Most `strange problems' are user error, so please try not to blame your tools. > When I try to > read a tab delimited file I get an error message for line 260 not being > equal to 14 (see below). Yes, but not line 260 in that file, but line 260 as read by scan(). Think about quotes ... it works for me with quote="", and the quote on ca line 150 is causing you to get some very large fields with embedded new lines and tabs. BTW, there is a 'R Data Import/Export' manual which goes through step-by-step the assumptions you make when using read.table with various options. Do read it now. > Using count.fields() suggests that a number of lines have length not > equal to 14, but not 260. > > Looking at the actual file, however, I cannot see anything wrong with > any lines. They all seem to have length 14, there are no double tabs > etc., and the file reads correctly in other programs. Does anyone have > any suggestions as to what this might stem from? > > I have placed a copy of the file at > http://dss.ucsd.edu/~kgledits/archigos_v.1.9.asc > > regards, > Kristian Skrede Gleditsch > > > > archigos1.9 <- read.table("c:/work/work12/archigos/archigos_v.1.9.asc", > + sep="\t",header=T,as.is=T,row.names=NULL) > Error in scan(file = file, what = what, sep = sep, quote = quote, dec = > dec, : > line 260 did not have 14 elements > > a <- count.fields("c:/work/work12/archigos/archigos_v.1.9.asc",sep="\t") > > a <- data.frame(c(1:length(a)),a) > > a[a[,2]!=14,] > c.1.length.a.. a > 150 150 10 > 313 313 10 > 424 424 10 > 1189 1189 5 > 1510 1510 10 > 1514 1514 10 > 1590 1590 5 > 1600 1600 10 > 1612 1612 10 > 1618 1618 10 > 1619 1619 10 > 1709 1709 10 > 1722 1722 10 > 1981 1981 10 > 1985 1985 10 > 2112 2112 10 > 2178 2178 10 > 2208 2208 10 > 2224 2224 10 > 2530 2530 5 > 2536 2536 5 > 2573 2573 5 > 2928 2928 5 > -- > Kristian Skrede Gleditsch > Department of Political Science, UCSD > (On leave, University of Essex, 2005-6) > Tel: +44 1206 872499, Fax: +44 1206 873234 > Email: [EMAIL PROTECTED] or [EMAIL PROTECTED] > http://weber.ucsd.edu/~kgledits/ > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html