I have run into a strange behavior if a function has an argument and the ellipse and the two start with the same letter. A toy example is this
> testfun=function(aa=0, ...) {print(aa); list(...)}
> testfun(b=1)
[1] 0
$b
[1] 1
> testfun(a=1)
[1] 1
list()
So when I call testfun(b=1)
everything works fine, aa
is printed as 0 and a list with element b=1 is returned. However, if I call testfun(a=1)
, aa is now 1 and an empty list is returned. Apparently if there is an argument that starts with the same letter as the one passed to ..., this argument gets changed and the ...
is lost.
Any idea why this is? Any way to avoid this? In my real problem the ... is supplied by users, who might use any name for the argument (except the ones that are already arguments for the function like aa here)