In the documentation of sapply
and replicate
there is a warning regarding using ...
Now, I can accept it as such, but would li
?replicate
, in the Examples section, tells us explicitly that what you are trying to do does not and will not work. In the Note
section of ?replicate
we have:
If ‘expr’ is a function call, be aware of assumptions about where
it is evaluated, and in particular what ‘...’ might refer to. You
can pass additional named arguments to a function call as
additional named arguments to ‘replicate’: see ‘Examples’.
And if we look at Examples, we see:
## use of replicate() with parameters:
foo <- function(x=1, y=2) c(x,y)
# does not work: bar <- function(n, ...) replicate(n, foo(...))
bar <- function(n, x) replicate(n, foo(x=x))
bar(5, x=3)
My reading of the docs is that they do far more than warn you about using ...
in replicate()
calls; they explicitly document that it does not work. Much of the discussion in that help file relates to the ...
argument of the other functions, not necessarily to replicate()
.