Description Usage Arguments Details Value Note Author(s) Examples
fun
captures its first argument unevaluated and turns it
into a function. Every name used in the expression becomes an
argument, unless it looks like a function call. If you don't
intend to capture a particular variable, you can not provide it,
and it will use a default value that pulls from the enclosing
scope.
1 |
expr |
The expression to use as the function's body. |
.all.names |
Whether to include call heads as parameters. |
"...
" is supported in the function definitions and should
behave as you expect.
A newly constructed function.
Since it doesn't know which symbols you intend to be arguments and which you intend to take from the enclosing environment, it captures all symbols in defaults; therefore it won't work as a closure that reflects changes in the enclosing environment.
Peter Meilstrup
1 2 3 4 5 6 7 | f <- fun(x/y)
f(10,2) # prints 5
f
# function (x = eval(quote(x),..fun_envir),
# y = eval(quote(y),..fun_envir) {
# x/y
# }
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.