R在alist中存储变量值

时间:2016-01-14 15:34:17

标签: r function defaults

我试图通过formals使用函数来修改另一个函数默认设置,但我的问题是,当我检查我的函数默认值之后,没有任何改变。我的代码(减去不相关的东西)是:

ScouringSettings <- function(min.MAF=NULL, eq.thresh=NULL){
  if (is.null(min.MAF) && is.null(eq.thresh)){
    maf <- paste0("Minimum MAF criterion is: ", formals(GeneScour)$min.maf)
    eq  <- paste0("Chi² HW equilibrium threshold: ", formals(GeneScour)$min.eq)
    cat(paste(maf, eq, sep="\n"))
  } else if (is.null(eq.thresh)) {
    formals(GeneScour) <- alist(gene=, min.maf = min.MAF, min.eq = formals(GeneScour)$min.eq)
  } else if (is.null()){
    formals(GeneScour) <- alist(gene=, min.maf = formals(GeneScour)$min.maf, min.eq = eq.thresh)
  } else {
    formals(GeneScour) <- alist(gene=, min.maf = min.maf, min.eq = eq.thresh)
  }
}

我认为这可能是因为范围问题或其他问题所以我尝试打印出默认设置,同时仍然在我的第一个功能中打印出来:

$gene

$min.maf
min.MAF

$min.eq
formals(GeneScour)$min.eq

即使我强行输入

formals(GeneScour) <- alist(gene=, min.maf = 2, min.eq = formals(GeneScour)$min.eq)

修改不会在ScouringSettings之外进行。

我有点迷茫,我怎么能管理它呢?

0 个答案:

没有答案