makeClosure | R Documentation |
This function takes a function and assigns it an environment and then puts the specified variables into that environment so that they are available when the function is called and not in the global search path.
This function is used when we dynamically generate code to interface to C routines.
makeClosure(fun, ..., .els = list(...), env = new.env())
fun |
the function whose environment is to be changed |
... |
|
.els |
a named list of values, providing an alternative way to specify the variables to be stored in the environment. |
env |
the environment to use as the function's environment |
The modified function whose environment is env
.
Duncan Temple Lang
The package RGCCTUFFI
(https://github.com/omegahat/RGCCTUFFI) has a related
createRFunc
function.
f = function(x, y)
x + y + z
f = makeClosure(f, z = 2, w = "not used")
f(1, 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.