使用write.csv时,防止将行名写入文件 [英] Prevent row names to be written to file when using write.csv
本文介绍了使用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:表示
'x'的行名称是否与x一起写入的逻辑值,或字符向量
要写入的行名称。
Commands:
t <- data.frame(v = 5:1, v2 = 9:5) write.csv(t, "t.csv")
Resulting file:
# "","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)
From
?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屋!
查看全文