Skip to content
Prev 48886 / 63421 Next

dubious behaviour of match.arg() with nested functions.

On 25-08-2014, at 16:27, Joris Meys <jorismeys at gmail.com> wrote:

            
Can?t  the problem easily be avoided by using a slightly modified version of the test2() function?

test2 <- function(x=c("q","r","s"),global=c("d","z","q")){
 x <- match.arg(x)
global <- match.arg(global)
 test(x=x,global=global)
}

Then test2() would be calling test() as it was intended to be called.
I?ve tried that and it appears to solve the problem.

So before calling nleqslv within another function use match.arg on those arguments with the same name and different defaults.
And (possibly) document that some arguments expect a single value.

Berend