2012-12-13 192 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)  
相關問題