[R] Why read.table replacing space with "." in the header

arun smartpink111 at yahoo.com
Mon Oct 7 14:35:59 CEST 2013


Hi,
Use `check.names=FALSE`
head(dd,2)
#  Phylo.Tree Genesis.Tree
#1          1            2
#2          2            3

 dd <- data.frame("Phylo Tree"= c(1:10), "Genesis Tree"= c(2:11),check.names=FALSE) 
head(dd,2)
#  Phylo Tree Genesis Tree
#1          1            2
#2          2            3
write.csv(dd,"Crish.csv",row.names=FALSE)
 yy<- read.csv("Crish.csv",header=TRUE,check.names=FALSE)
 head(yy,2)
#  Phylo Tree Genesis Tree
#1          1            2
#2          2            3

A.K.



Hello Guys 

Please look at the following code. I dont have "." in the input 
data frame. But why i am getting when i read the data.frame again. 

dd <- data.frame("Phylo Tree"= c(1:10), "Genesis Tree"= c(2:11)) 
 write.table(dd, "D:\\Write_XML\\testdf.csv", sep=",") 
 yy <- read.table("D:\\Write_XML\\testdf.csv", sep=",") 
 names(yy) 
[1] "Phylo.Tree"   "Genesis.Tree" 


Thanks 
Krishna



More information about the R-help mailing list