简体   繁体   中英

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 ).

We can use substitute

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM