小编典典

使用 write.csv 时防止将行名写入文件

all

命令:

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

如何防止将具有行索引的第一列写入文件?


阅读 64

收藏
2022-07-28

共1个答案

小编典典

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.
2022-07-28