简体   繁体   English

R write.table约定

[英]R write.table conventions

Why is the R write.table() function set to quote column names and label row.names by default? 为什么默认情况下将R write.table()函数设置为引用列名和标签row.names?

Also, is it possible to change these defaults so that they do not need to be manually changed in every call of write.table used in a script? 另外,是否可以更改这些默认值,以便不需要在脚本中使用的每次write.table调用中都手动更改它们?

Just like in studying nature, we generally don't know WHY. 就像研究自然一样,我们通常不知道为什么。 It is because R gods said so. 这是因为R诸神这么说。 This reminds me of stringsAsFactors being TRUE by default, which doesn't suit a certain type of users. 这让我想起stringsAsFactors在默认情况下为TRUE ,不适合某些类型的用户。 The beautiful thing about all this is that you can always change it to meet your needs. 所有这一切的美丽之处在于您可以随时更改它以满足您的需求。

What you can do is overwrite the function with custom default values in your .Rprofile (see this question ) or even better, make your own personal R package (perhaps using GitHub? ) that implements the same function using different defaults. 您可以做的是用.Rprofile自定义默认值覆盖该函数(请参阅此问题 ),甚至更好的是,制作自己的个人R包(也许使用GitHub? ),以使用不同的默认值实现相同的功能。

您还可以复制的r write.table()到自定义的功能,如write.table2()函数,则改变逻辑论证的默认值quotewrite.table2()为false。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM