NB: This question is not a duplicate of How to use R's ellipsis feature when writing your own function?. That question asks how to use ellipses, and in particular, "how can [one] convert the ellipsis from the function's signature into, for example, a list?" Below I don't ask anything of the sort. I am asking why my use of ellipses fails to produce the expected result.
As an example, the function my.ls
below is meant to be a wrapper around base::ls
that makes all.names = TRUE
the default:
my.ls <- function (...) base::ls(..., all.names = TRUE)
I had expected that, with this definition, my.ls()
would produce the same value as base::ls(all.names = TRUE)
does. To my surprise, the values from these two expressions are not even close.
For example:
% /usr/bin/R --quiet --vanilla
> x <- 3; .y <- 1; z <- 4
> base::ls(all.names = TRUE)
[1] "x" ".y" "z"
> my.ls <- function (...) base::ls(..., all.names = TRUE)
> my.ls()
[1] "..."
What am I doing wrong?