Change default arguments of an R function at runtime

后端 未结 4 2192
离开以前
离开以前 2021-02-19 22:59

Is it possible to change the default values of formal parameters in an R function at runtime?

Let\'s assume, we have the function

f <- function(x=1) {         


        
4条回答
  •  暖寄归人
    2021-02-19 23:40

    An alternative (shown in a different SO post) is to use the formals function, e.g.:

    formals(f) <- 2

提交回复
热议问题