Do you always use row.names = F in write.csv? Changing default values ​​inside R (base) functions

I could not find a solution on the Internet, but I thought it could be quite common.

With write.csv, I usually always have the row.name argument equal to F. Is it possible to run the line once and update the default argument for the rest of the session?

I tried:

paste <- paste(sep="") 

which ran and did not return errors, but seemed to do nothing (and did not destroy the insert function). This is another one, I always set sep to "with paste, as if I always have" exclude = NULL "when I use a table so that I can see N / A values.

EDIT: So, I'm looking for a solution that will work for several functions, if possible, paste, write.csv, table and other functions like these.

thanks

+8
r
source share
2 answers

Try the following:

 paste <- paste formals(paste)$sep <- "" 

This will create a new copy of paste in your workspace, and then change the default value for sep to "" . Subsequent calls to paste will use the modified copy as it sits in front of the base environment in your search path.

+5
source share

paste <- paste(sep="") puts the output of paste() into an object named "paste". You will need to do something like this.

 paste <- function (..., sep = "", collapse = NULL) { base::paste(..., sep=sep, collapse=collapse) } 

You can also look at the Defaults package for these kinds of things, but currently it does not work for your two examples.

+8
source share

All Articles