[R] Error with named definition argument to match.call
William Dunlap
wdunlap at tibco.com
Wed Jul 16 02:04:20 CEST 2014
Does it make sense to call match.call outside of a function without
specifying both the function definition and the call to the function?
I agree that the error message is misleading. Also, the return value
when call is not supplied does not seem useful, although it is
possible that it is correct in some technical sense.
> match.call(definition=function(FirstArg, SecondArg)NULL, quote(anyFuncName(S=2, 1)))
anyFuncName(FirstArg = 1, SecondArg = 2)
> match.call(function(FirstArg, SecondArg)NULL, quote(anyFuncName(S=2, 1)))
anyFuncName(FirstArg = 1, SecondArg = 2)
> # without supplying 'call':
> match.call(definition=function(FirstArg, SecondArg)NULL)
Error in match.call(definition, call, expand.dots) :
unused argument (definition = function(FirstArg, SecondArg) NULL)
> match.call(function(FirstArg, SecondArg)NULL)
match.call(FirstArg = function(FirstArg, SecondArg) NULL)
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Jul 15, 2014 at 4:27 PM, David Winsemius <dwinsemius at comcast.net> wrote:
> The help page says:
>
> "Calling match.call outside a function without specifying definition is an
> error."
>
> And yet when I send a function with a 'definition' argument it errors:
>
>> g
> function(x, y=NULL, z=NULL) invisible(NULL)
>> match.call(definition=g)
> Error in match.call(definition, call, expand.dots) :
> unused argument(s) (definition = g)
>
> I wondered if this had something to do with primitive functions and their
> ignoring names but:
>
>> is.primitive(match.call)
> [1] FALSE
>
> Calling with an unnamed first argument succeeds:
>
>> match.call(g )
> match.call(x = g)
> --
>
> David Winsemius, MD
> Alameda, CA, USA
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list