nathaneastwood
nathaneastwood

Reputation: 3764

match.call() returns ..1 when evaluated in a sub function

I have two functions

fn1 <- function(...) {
  fn2(...)
}

I have a second function

fn2 <- function(...) {
  match.call(expand.dots = FALSE)$...
}

Calling the first function with a symbol does not return the expected value

fn1(test)
# [[1]]
# ..1

I would expect test to be returned (a symbol).

Upvotes: 1

Views: 47

Answers (1)

akrun
akrun

Reputation: 887028

We can use substitute

fn2 <- function(...) {
     eval(substitute(alist(...) ))

   }
fn2(test)
#[[1]]
#test
fn1(test)
#[[1]]
#test

Upvotes: 2

Related Questions