Displaying 1 result from an estimated 1 matches for "myrepl".
Did you mean:
myrepo
2007 Nov 17
1
protecting "..."
Dear expRts,
I just realized that the "..." argument in a function cannot be used without
taking precautions sometimes. The following behaviour is what I stumbled
upon:
> myrepl <- function(length, fun, ...) {
+ replicate(length, fun(...))}
> myrepl(20, sample, 1:5)
[1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> myotherrepl <- function(length, fun, ...) {
+ args <- list(...)
+ replicate(length, do.call(fun, args))}
> myotherrepl(20, sample, 1:5)
[,1]...