如何获取包含传递给函数的点-点-点参数名称的字符向量,例如:
test<-function(x,y,...)
{
varnames=deparseName(substitute(list(...)))
# deparseName does not exist, this is what I want !
# so that I could *for example* call:
for(elt in varnames)
{print(varnames);}
}
v1=11
v2=10
test(12,12,v1,v2)
## would print
#v1
#v2
最佳答案
试试这个:
test<-function(x,y,...)
{
mc <- match.call(expand.dots = FALSE)
mc$...
}
v1=11
v2=10
test(12,12,v1,v2)
[[1]]
v1
[[2]]
v2
关于r - 如何在 R 中获取点-点-点参数的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51259346/