Re: [R] read.table

From: Marc Schwartz <MSchwartz_at_mn.rr.com>
Date: Thu 19 Oct 2006 - 20:28:54 GMT

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



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 and provide commented, minimal, self-contained, reproducible code. Received on Fri Oct 20 06:31:15 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 19 Oct 2006 - 21:30:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.