[R] Problem with read.table()

From: Kristian Skrede Gleditsch <kgleditsch_at_ucsd.edu>
Date: Thu 21 Jul 2005 - 23:11:36 EST


Dear all,

I have encountered a strange problem with read.table(). When I try to read a tab delimited file I get an error message for line 260 not being equal to 14 (see below).

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: kgleditsch@ucsd.edu or ksg@essex.ac.uk
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
Received on Thu Jul 21 23:16:43 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:53 EST