2012-12-13 46 views
1

我创建了一个函数Dummyfunc,它计算不同样本的倍数变化。 我在Dummyfunc函数中使用gsva函数。我想从我的Dummyfunc访问gsva函数的所有参数,以便我可以根据需要更改参数的值。 到目前为止,我已经尝试做这样的: -用R中另一个函数的参数创建函数

Dummyfunc <- function(method="gsva",verbose=TRUE,kernel=){ 
gsva(method=method,kernel=kernel,verbose=verbose) 
} 

但是否能以自动方式进行,以便gsva函数的所有参数可以从Dummyfunc

回答

1

访问我真的不知道你是什么在之后,但是将使用...。例如:

Dummyfunc = function(...) 
    gsva(...) 

Dummyfunc = function(method="gsva", verbose=TRUE, ...) 
    gsva(method=method, verbose=verbose, ...) 

我们使用...传递任何额外的参数。

1

如果我正确地理解了你的问题,你应该只是通过它们全部与...你可能会写出他们全部,但这可能需要一段时间。

# define the internal function 
f.two <- 
    function(y , z){ 
     print(y) 
     print(z) 
    } 

# define the external function, 
# notice it passes the un-defined contents of ... on to the internal function 
f.one <- 
    function(x , ...){ 
     print(x) 

     f.two(...) 

    } 

# everything gets executed properly 
f.one(x = 1 , y = 2 , z = 3)  
相关问题