[Rd] [R] unvectorized option for outer()
murdoch at stats.uwo.ca
Tue Nov 1 16:56:54 CET 2005
On 11/1/2005 10:16 AM, Thomas Lumley wrote:
> On Tue, 1 Nov 2005, Duncan Murdoch wrote:
>> The version I posted yesterday did indeed mess up when some arguments were
>> unspecified. Here's a revision that seems to work in all the tests I can
>> think of. I also added the SIMPLIFY and USE.NAMES args from mapply to it,
>> and a sanity check to the args.
>> I did notice and work around one buglet in mapply: if you choose not to
>> vectorize any arguments, you don't get a call to the original function,
>> mapply returns "list()".
>> For example,
>>> mapply(function(x) x^2, MoreArgs = list(x=2))
>> whereas I would think 4 is a more logical answer.
> I don't agree at all. The answer should be the length of the longest
> vectorised argument, and it is.
I do agree that if I'd specified something like
mapply(function(x) x^2, x=numeric(0))
then the answer (which is again list()) would be correct. But
what is the length of the longest item in an empty set? I'd say it's
More information about the R-devel