Change the default value in a built-in function

别等时光非礼了梦想. 提交于 2019-12-24 16:17:43

问题


I was wondering if it is possible to change the default value for a built-in function in R? I have found some questions about setting default values for user made functions in R, but not for built-in functions.

Why do I want this? To be honest, it is purely a matter of convenience. Sometimes I write my results/data to a .csv file to make some quick graphs in Excel. To do this I use the write.csv function. One of the defaults in this function is row.names = TRUE. So far, I have never wanted the row.names in my Excel file and I have forgotten to add row.names = FALSE to the function dozens of times. So is it possible to change the default value in this function to row.names = FALSE?


回答1:


No. But if you want convenience, write a wrapper function yourself. For example:

my_write.csv <- function(...) write.csv(..., row.names = FALSE)

then you use my_write.csv.



来源:https://stackoverflow.com/questions/38501035/change-the-default-value-in-a-built-in-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!