我试图通过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
之外进行。
我有点迷茫,我怎么能管理它呢?