使用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
如何防止将行索引的第一列写入文件?
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.