How do I call the `function` function?

前端 未结 3 1556
后悔当初
后悔当初 2020-12-15 04:07

I am trying to call the function `function` to define a function in R code.

As we all know™️, `function`is a .Primitive that’s

3条回答
  •  轮回少年
    2020-12-15 04:31

    For completeness’ sake, lionel’s answer hints at a way of calling `function` after all. Unfortunately it’s rather restricted, since we cannot pass any argument definition except for NULL:

    mean5 = `function`(NULL, mean(x, ...))
    formals(mean5) = formals(mean)
    

    (Note the lack of quoting around the body!)

    This is of course utterly unpractical (and formals<- internally calls as.function anyway.)

提交回复
热议问题