![](/img/trans.png)
[英]Pass function arguments that are variable names into formulae in R functions?
[英]pass arguments to the R function from a variable
我有一個帶有以下標頭的R函數:
getFileNames <- function(sex=NULL,species=NULL,name=NULL){
當我這樣稱呼時,一切都很好:
getFileNames(sex="F",species="Pan paniscus")
但是,我想用這樣的變量filters
來稱呼它:
getFileNames(filters)
現在,我試圖弄清楚如何定義filters
。 我努力了
filters<-paste("sex=F","species=Pan paniscus",sep=",")
沒有成功。
最好的辦法是使用do.call
:
filters = list(sex="F",species="Pan paniscus")
do.call(getFileNames, filters)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.