Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Couldn't see a solution online but I thought this might be quite common.

  • with write.csv I basically always have the argument row.name set to F. Is it possible to run a line once and update the default value of the argument for the rest of the session?
  • I tried paste <- paste(sep="") which ran and returned no error but seemed to do nothing (and didn't destroy the paste function). This is another one, I always set sep="" with paste...
  • like I always have exclude=NULL when I am using table so I can see the N/A values.

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

like image 586
nzcoops Avatar asked Jul 11 '11 03:07

nzcoops


1 Answers

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

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

You can also look at the Defaults package for this sort of thing, but it doesn't currently work for two of your examples.

like image 121
Joshua Ulrich Avatar answered Oct 30 '22 13:10

Joshua Ulrich