[R] Problem with read.table()

Richard.Cotton at hsl.gov.uk Richard.Cotton at hsl.gov.uk
Thu Oct 2 12:43:50 CEST 2008


> I'm a new user and I'm trying to use read.table with a tab delimited 
> file but the system tells me (i) that there are more columns than 
> column names, and (ii) that headers and col.names are of different 
> lengths. I have already checked my variable names and there's no blank 
> spaces. However, some variables have quite long names such as 
> "valoracion.experiencias.segundo.year". Could it be the problem? If 
> that is the case, I still don't understand why I have more columns 
> that column names. Could anyone help me with that?

It is unlikely to be due to the long variable names.  Without seeing your 
data, it is impossible to say for sure what the problem is, but here are 
some things to check.

Have you set the 'sep' argument to "\t"?  Otherwise read.table may get 
confused and interpret tabs as multiple spaces.  Alternatively, use 
read.delim, which is a wrapper for read.table made especially for tab 
delimited files.

Are there any tabs at the ends of lines?

Are there any text variables with spaces, that aren't enclosed on quotes?

Regards,
Richie.

Mathematical Sciences Unit
HSL


------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}



More information about the R-help mailing list