Johannes Hüsing wrote: > Duncan Murdoch <[EMAIL PROTECTED]> [Sat, Nov 17, 2007 at 11:56:52PM CET]: > >> On 17/11/2007 5:04 PM, Johannes Hüsing wrote: >> >>> I just realized that the "..." argument in a function cannot be used >>> without >>> taking precautions sometimes. The following behaviour is what I >>> stumbled upon: >>> >> The problem is the way replicate is implemented. It takes the >> expression, and wraps it in a function(...) before calling sapply. The >> ... in your expression matches the ... in the wrapper function, not the >> ... from the parent. >> > > Many thanks! Pose a question, go to sleep, wake up, read the answer. > I feel like being in old Cologne > (http://en.wikipedia.org/wiki/Heinzelm%C3%A4nnchen). > > > >> I think you'll need to make calls to sapply directly to do what you >> want. >> >> > > Do you mean to replace "replicate" by the contents of the function? > I am feeling more comfortable with my solution. What I meant was something like this:
myrepl2 <- function(length, fun, ...) { iterfun <- function(n) fun(...) sapply(integer(length), iterfun) } but your solution works too. Duncan Murdoch ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.