search for: myotherrepl

Displaying 1 result from an estimated 1 matches for "myotherrepl".

2007 Nov 17
1
protecting "..."
..."..." 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] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [1,] 1 2 3 4 3 1 5 4 1 3 1 1 5 2 [2,]...