[R] read.table

Marc Schwartz MSchwartz at mn.rr.com
Thu Oct 19 22:28:54 CEST 2006


On Thu, 2006-10-19 at 16:10 -0400, Weiwei Shi wrote:
> hi,
> 
> how could I let the colname be the numbers instead of "X" plus numbers
> when I use read.table. Or there is an alternative way?
> 
> thanks

Sounds like you have imported the data, perhaps using 'header = TRUE'
either without an actual header row of column names or perhaps an
incomplete or improper (not syntactically valid) header row. 

If you are getting X's (and not V's) pre-pended to the column names,
that sounds like the result of make.names() on your data. 

See ?make.names

If you don't have a header row in the imported data set, you can use the
'colnames' argument in read.table() to explicitly provide them. Just be
sure to set 'header = FALSE'.

If there is a header row, but it is problematic, set 'header = FALSE'
AND 'skip = 1', which will skip over the first row in the incoming file.

See ?read.table

HTH,

Marc Schwartz



More information about the R-help mailing list