使用 write.csv 时防止将行名称写入文件 [英] Prevent row names to be written to file when using write.csv

查看:23
本文介绍了使用 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

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

How do I prevent first column with row index from being written to the file?

推荐答案

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.

这篇关于使用 write.csv 时防止将行名称写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆