[R] read.table with numeric row names

kexinz zhangchicool at gmail.com
Fri Jul 13 00:00:29 CEST 2012


Thanks, but I don't want to specify the column names by hand, since I have a
lot of similar files.


arun kirshna wrote
> 
> Hi,
> 
> Try this:
> 
> dat1<-read.table(text="
>  2.5  3.6  7.1  7.9
>  100  3      4      2    3
>  200  3.1  4      3      3
>  300  2.2  3.3  2    4
>  ",sep="",header=TRUE)
> #Either
> 
> colnames(dat1)<-c("2.5","3.6","7.1","7.9")
> #or
> 
> colnames(dat1)<-c(2.5,3.6,7.1,7.9)
> #produce character column names
> 
> 
>  is.character(colnames(dat1))
> [1] TRUE
>  is.numeric(colnames(dat1))
> [1] FALSE
> 
> 
> dat1
>     2.5 3.6 7.1 7.9
> 100 3.0 4.0   2   3
> 200 3.1 4.0   3   3
> 300 2.2 3.3   2   4
> 
> 
> A.K.
> 
> 


--
View this message in context: http://r.789695.n4.nabble.com/read-table-with-numeric-row-names-tp4636342p4636378.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list