Using “…” and “replicate”

前端 未结 4 1024
庸人自扰
庸人自扰 2020-12-20 11:47

In the documentation of sapply and replicate there is a warning regarding using ...

Now, I can accept it as such, but would li

4条回答
  •  孤城傲影
    2020-12-20 11:57

    An alternative way to do that:

    g <- function(x, y) x + y
    
    f <- function(a = 1, ...) {
        arg_list <- list(...)
        replicate(n = 3, expr = do.call(g, args = arg_list))
    }
    
    f(x = 1, y = 2)
    

提交回复
热议问题