amatch(definition, call) match.call(definition=<<see below>>, call=<<see below>>, expand.dots=T)
match.call returns a call in which all of the arguments are specified by name. Therefore, components of this object corresponding to argument names in the definition will be the actual, unevaluated argument if one was given, or else NULL. A particularly common use is to get the call of the current function, with arguments named.
Note that functions sys.call and sys.function are general ways to get at a functions own call and definition. match, charmatch are other matching functions. To convert a call into a string, use deparse (useful for making plot titles out of calls). Use eval to reevaluate the call, perhaps with different data.
amatch(function(x = 2, y = 3, abc = "hi", ...){}, expression(fun(x1, ab = 7, c = x2)))# this produces the following output: $x: amp;.Argument(x1, x = 2)
$y: amp;.Argument(, y = 3)
$abc: [1] 7
$...: amp;.Argument((c = x2), ... = )
attr(, "missing"): [1] F T F F
# Return a matched version of my own call as an attribute
myfunction <- function(formula, data, weights, subset, ...){ value <- "Not computed" attr(value, "call") <- match.call() value } myfunction(data=solder, skips ~ Mask, plot = F)
[1] "Not computed" attr(, "call"): myfunction(formula = skips ~ Mask, data = solder, plot = F)
# 3rd example: match.call(get, expression(get("abc", w=2)))
# gives the output: get(name = "abc", where = 2)
# 4th example: match.call(rm, expression(rm(foo1, foo2))) rm(foo1, foo2)
# 5th example: match.call(rm, expression(rm(foo1, foo2)), expand.dots=F)
rm(... = list(foo1, foo2))