【发布时间】:2017-12-21 11:41:35
【问题描述】:
假设我有一个 function 需要另外两个 functions 和一些 arguments 作为 arguments:
a <- function(x, y = 2){
x + y
}
b <- function(b1, b2 = 7){
b1 + b2
}
x <- function(x1, x2){
# Get arguments of arguments
}
有没有办法从x() 参数中获取arguments 的列表?这是,通话后:
x(a(3,4), b(5))
我想得到如下列表:
$x1
$x1$x
[1] 3
$x1$y
[1] 4
$x2
$x2$b1
[1] 5
$x2$b2
[1] 7
【问题讨论】:
-
可能是
x <- function(x1, x2) as.list(match.call())[-1]或x <- function(x1, x2) lapply(as.list(match.call())[-1], as.list)`