2011-09-20 30 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