简体   繁体   English

match.call() 在子 function 中评估时返回..1

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

I have two functions我有两个功能

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

I have a second function我有第二个 function

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

Calling the first function with a symbol does not return the expected value用符号调用第一个 function 不会返回预期值

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

I would expect test to be returned (a symbol ).我希望test返回(一个symbol )。

We can use substitute我们可以使用substitute

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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