Skip to content

Use of the dot.dot.dot option in functions.

3 messages · Duncan Murdoch, Kenneth Cabrera

#
On 06/04/2011 12:04 PM, KENNETH R CABRERA wrote:
I imagine it's a scoping problem: replicate() is probably not evaluating 
the ... in the context you think it is.  You could debug this by writing 
a function like

showArgs <- function(n, ...) {
   print(n)
   print(list(...))
}

and calling f1(n=10, fun=showArgs), but it might be easier just to avoid 
the problem:

f1 <- function(nsim=20,n=10,fun=rnorm,...){
     force(fun)
     force(n)
     localfun <- function() fun(n, ...)
     vp<-replicate(nsim,t.test(localfun(), localfun())$p.value)
     return(vp)
}