[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ base  (version  3.6.2  ) ](/packages/base/versions/3.6.2)

#  match.call: Argument Matching

##  Description

` match.call ` returns a call in which all of the specified arguments are
specified by their full names.

##  Usage

    
    
    match.call(definition = sys.function(sys.parent()),
               call = sys.call(sys.parent()),
               expand.dots = TRUE,
               envir = parent.frame(2L))

##  Arguments

definition

a function, by default the function from which ` match.call ` is called. See
details.

call

an unevaluated call to the function specified by ` definition ` , as generated
by ` [ call ](/link/call?package=base&version=3.6.2) ` .

expand.dots

logical. Should arguments matching ` … ` in the call be included or left as a
` … ` argument?

envir

an environment, from which the ` … ` in ` call ` are retrieved, if any.

##  Value

An object of class ` call ` .

##  Details

‘function’ on this help page means an interpreted function (also known as a
‘closure’): ` match.call ` does not support primitive functions (where
argument matching is normally positional).

` match.call ` is most commonly used in two circumstances:

  * To record the call for later re-use: for example most model-fitting functions record the call as element ` call ` of the list they return. Here the default ` expand.dots = TRUE ` is appropriate. 

  * To pass most of the call to another function, often ` model.frame ` . Here the common idiom is that ` expand.dots = FALSE ` is used, and the ` … ` element of the matched call is removed. An alternative is to explicitly select the arguments to be passed on, as is done in ` lm ` . 

Calling ` match.call ` outside a function without specifying ` definition ` is
an error.

##  References

Chambers, J. M. (1998) _Programming with Data. A Guide to the S Language_ .
Springer.

##  See Also

` [ sys.call ](/link/sys.call?package=base&version=3.6.2) () ` is similar, but
does _not_ expand the argument names; ` [ call
](/link/call?package=base&version=3.6.2) ` , ` [ pmatch
](/link/pmatch?package=base&version=3.6.2) ` , ` [ match.arg
](/link/match.arg?package=base&version=3.6.2) ` , ` [ match.fun
](/link/match.fun?package=base&version=3.6.2) ` .

##  Examples

[ Run this code
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fmatch.call&utm_source=r-docs&utm_medium=docs&utm_term=match.call&utm_content=run_example_in_workspace)

    
    
    # NOT RUN {
    match.call(get, call("get", "abc", i = FALSE, p = 3))
    ## -> get(x = "abc", pos = 3, inherits = FALSE)
    fun <- function(x, lower = 0, upper = 1) {
      structure((x - lower) / (upper - lower), CALL = match.call())
    }
    fun(4 * atan(1), u = pi)
    # }
    

Run the code above in your browser using  [ DataCamp Workspace
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fmatch.call&utm_source=r-docs&utm_medium=docs&utm_term=match.call&utm_content=run_example_in_workspace)

Powered by  [ DataCamp ](https://www.datacamp.com/)