Strange argument parsing in write.csv

r

Solution

You don't get any partial argument matching inside of `write.csv` because `write.csv`'s only argument is `...`. So `write.csv`'s attempt to manipulate your call fails here:

rn <- eval.parent(Call$row.names)
Call$col.names <- if (is.logical(rn) && !rn) TRUE else NA

And `row.n` is matched to `row.names` in the call to `write.table`, but the `write.table` call generated by `write.csv` is:

write.table(irfilt, "foo.bar", row.n = FALSE, col.names = NA,
            sep = ",", dec = ".", qmethod = "double")

Which is why you're getting the error about `col.names = NA` while `row.names = FALSE`.

Problem

Consider the following two commands: ``` > write.csv(irfilt,'foo.bar',row.names=FALSE) #works fine but: > write.csv(irfilt,'foo.bar',row.n=FALSE) Error in write.table(irfilt, "foo.bar", row.n = FALSE, col.names = NA, : 'col.names = NA' makes no sense when 'row.names = FALSE' ``` I would have expected `row.n` to auto-expand to `row.names` but apparently that's not happening. There isn't any other allowed argument to `write.table` which could be confused with `row.names`. Does anyone know what is causing this misinterpretation? I thought it might be related to the fact that `write.csv` has no named arguments, but it seems odd that I wouldn't just get an error message about an unknown argument, rather than a misinterpreted arg.

Original source