match.call(definition = sys.function(sys.parent()), call = sys.call(sys.parent()), expand.dots = TRUE, envir = parent.frame(2L))
definition | a function. This argument is optional if match.call is called from inside another function, in which case the default is the function that calls match.call. |
call | an unevaluated call to the function given in definition. This argument is optional if match.call is called from inside another function, in which case the default is the call of the function that calls match.call. |
expand.dots | a logical flag. If TRUE (the default), a call involving the ... construct has the arguments corresponding to ..., separated by commas, along with the other arguments. If FALSE, the ... arguments are grouped together in a list, as the value of a single argument named .... |
envir | an environment used for retrieving the values of the ... argument in the call, if any. By default, if match.call is called from inside another function, this is the environment of the function that calls match.call. |
# 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 } mydata <- data.frame(x=1:10,y<-sin(1:10)) myfunction(data=mydata, y ~ x, plot = F) # returns: # [1] "Not computed" # attr(, "call"): # myfunction(formula=y ~ x, data=mydata, plot=F)# specify definition, call match.call(function(name,where,frame) NULL, expression(get("abc", w=2))) # returns: get(name = "abc", where = 2)
# function with ... arg match.call(function(...) NULL, expression(rm(foo1, foo2))) # returns: rm(foo1, foo2) match.call(function(...) NULL, expression(rm(foo1, foo2)), expand.dots=F) # returns: rm(... = list(foo1, foo2))