match.call2: Alternate Parametrisation of 'match.call()'

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Alters the built-in function match.call() by providing an additional argument which means that by default a user can specify how far up the call stack they want to match a call of. See match.call() for more details.

Usage

1
2
3
4
5
6
7
match.call2(
  n = 0L,
  definition = sys.function(sys.parent(n + 1L)),
  call = sys.call(sys.parent(n + 1L)),
  expand.dots = TRUE,
  envir = parent.frame(n + 3L)
)

Arguments

n

How far up the call-stack they would like to extract. The default, n=0 produces the same result as match.call() so this can be inserted wherever match.call() is used.

definition

a function, by default the function from which match.call2() is called.

call

an unevaluated call to the function specified by definition, as generated by call

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
f <- function(n) {
  g(n)
}

g <- function(n) {
  h(n)
}

h <- function(n) {
  match.call2(n)
}

f(0)
f(1)
f(2)

rando documentation built on Feb. 16, 2021, 5:07 p.m.