2011-09-20 29 views
95

命令到文件:防止行名稱使用write.csv時

t <- data.frame(v = 5:1, v2 = 9:5) 
write.csv(t, "t.csv") 

生成的文件:

# "","v","v2" 
# "1",5,9 
# "2",4,8 
# "3",3,7 
# "4",2,6 
# "5",1,5 

我如何防止行索引第一列被寫入文件?

回答

182
write.csv(t, "t.csv", row.names=FALSE) 

?write.csv

row.names: either a logical value indicating whether the row names of 
      ‘x’ are to be written along with ‘x’, or a character vector 
      of row names to be written. 
+9

我很慚愧,因爲我也嘗試write.csv但是... THX AIX?! – watbywbarif

+3

是的,訣竅是瞭解這個列表示行名稱。 – Vanuan