0

The R base package contains a function called function. Its help page tell us to call it as 'function( arglist ) expr'. I can use this syntax, but I was wandering if it is possible to call it as most R functions, namely something like 'FuncName( arg1, arg2 )'. In other terms is it possible to put 'expr' within the parenthesis? More explicitly, can I write ``function`( args, body )?

Thanks

user7669
  • 638
  • 4
  • 13
  • 1
    I'm not sure, but maybe [this](http://stackoverflow.com/q/12982528/324364) might be helpful. – joran Mar 15 '16 at 14:53
  • I'm not completely clear on what you are asking, but `function` isn't really a function, it's a [special keyword](https://github.com/wch/r-source/blob/trunk/src/main/gram.c#L4029-L4058). – nrussell Mar 15 '16 at 15:00
  • @joran Thanks. It shows that `args <- pairlist(a = 1, b = 2)` `body <- quote(a + b)` `myf <- eval( `function`(args, body) )` works. This is almost the answer (apart from the use of `eval`). – user7669 Mar 15 '16 at 18:49
  • @nrussell Tanks. I didn't realize this. – user7669 Mar 15 '16 at 18:56

0 Answers0