Skip to content
Prev 18329 / 63424 Next

unvectorized option for outer()

Duncan Murdoch wrote:
Thanks for explanation about the environment.

I should have said, that manipulation of the body creates the call
   mapply(FUN, A, alpha, MoreArgs=list(...))
from the original (x is a dummy argument)
   mapply(FUN, x, MoreArgs=list(...))

Are there better ways to create that call?  The difficulty is that the 
argument names in the call are derived from the actual arguments to 
Vectorize(), and there is an arbitrary number of them.

As for the formals of the result being identical to the formals of the 
input, I couldn't see any easy way to do that and still support optional 
arguments, e.g., if the input function formals were (a, b, t=1), then 
the result function would look something like:

function(a, b, t=1) mapply(FUN, a, b, t=t)

and missing(t) would not work correctly within FUN (with even more 
serious problems for optional arguments with no defaults).

-- Tony Plate