marc_schwartz at comcast.net
Fri Oct 19 15:46:15 CEST 2007
See ?make.names, specifically the Details section which notes:
A syntactically valid name consists of letters, numbers and the dot or
underline characters and starts with a letter or the dot not followed by
a number. Names such as ".2way" are not valid, and neither are the
The character "X" is prepended if necessary. All invalid characters are
translated to ".". A missing value is translated to "NA". Names which
match R keywords have a dot appended to them. Duplicated values are
altered by make.unique.
Thus, your current column names in the header are not valid and the 'X'
is prepended. You could feasibly set 'check.names' in read.table() to
FALSE, however, that will introduce other issues.
In terms of the 'name' column being converted to a factor, this is the
default behavior. See ?read.table and take note of the
A factor has an underlying data type of integer, which is why you get
the behavior you observe:
On Fri, 2007-10-19 at 15:30 +0200, Neuer Arkadasch wrote:
> Maybe I had to write that the original data what I read are
> name 20_1_TT_Z_e4 20_2_TT_Z_e4
> A1 102 22
> A2 103 21
> A3 107 20
> Thatk you!
> Neuer Arkadasch <neuer_arkadasch at yahoo.de> schrieb:
> Hi everyone, I read the following data
> > setwd("d:/")
> > mydata <- read.table("mydata.txt", header=T)
> > attach(mydata)
> > mydata
> name X20_1_TT_Z_e4 X20_2_TT_Z_e4
> 1 A1 102 22
> 2 A2 103 21
> 3 A3 107 20
> > name
>  A1 A2 A3
> Levels: A1 A2 A3
> > mode(name)
>  "numeric"
> Why name is a factor and numeric? and why I do have X before the
> variable namin X20_1_TT_Z_e4? Is it possbile to have it as
> 20_1_TT_Z_e4 ?
More information about the R-help