[R] Error with named definition argument to match.call
David Winsemius
dwinsemius at comcast.net
Wed Jul 16 02:19:40 CEST 2014
On Jul 15, 2014, at 5:04 PM, William Dunlap wrote:
> Does it make sense to call match.call outside of a function without
> specifying both the function definition and the call to the function?
My puzzlement came from the different response to these two commands:
match.call(g)
match.call(definition=g)
I thought they would be the same. So you are saying to make sense this
would need to be
> match.call(definition=g , call=quote(g(1)) )
g(x = 1)
--
David.
> 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.
David Winsemius, MD
Alameda, CA, USA
More information about the R-help
mailing list