We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
No, there's no NULL; "not set" here was intended to mean the user not setting it, not the default not being defined in the function signature. When the user does not explicitly specify an argument for the parameter in this case, the default vector is passed through, triggering the behavior you correctly describe.
Extremely enlightening blog post, thank you! I'm glad I found this when I, too, was wondering about the inner life of match.arg.
Good read ! R is full of quirks and features.
I have doubts about your explanation of the
optimfunction.You said
which suggests the reason match.arg returns the first choice is because method is provided NULL.
But as you mentioned in your post, the method argument of
optimis not null (Seeformals(optim)$method).I believe what actually happens is when match.arg is called with only one argument (eg.
match.arg(method)), choice are obtained from the formal argument which in this case is identical to method. When arg and choice are identical, match.arg will return the first element of choice. (See line 13 -14 in match.arg source code)Let me know your thoughts on this.
Thanks!
Shu