[Rd] write.csv and match.call

Hadley Wickham hadley at rice.edu
Mon May 2 16:40:28 CEST 2011

Hi all,

Can help me understand why write.csv manipulates a call object instead
of simply calling write.table with modified arguments? I would have
written write.csv as:

write.csv <- function (...) {
    Call <- match.call(expand.dots = TRUE)
    for (argname in c("append", "col.names", "sep", "dec", "qmethod")) {
      if (!is.null(Call[[argname]]))
        warning(gettextf("attempt to set '%s' ignored", argname),
            domain = NA)

    write.table(..., sep = ",", dec = ".", qmethod = "double")

The current approach breaks partial argument matching for row.names:

write.csv(mtcars, "mtcars-1.csv", row = F)
write.table(mtcars, "mtcars-2.txt", row = F)
write.csv(mtcars, "mtcars-2.csv", row.names = F)

What's the advantage of manipulating the call?


Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University

More information about the R-devel mailing list