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?

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to