crate {mlr3misc} | R Documentation |
Isolate a Function from its Environment
Description
Put a function in a "lean" environment that does not carry unnecessary baggage with it (e.g. references to datasets).
Usage
crate(.fn, ..., .parent = topenv(), .compile = TRUE)
Arguments
.fn |
( |
... |
(any) |
.parent |
( |
.compile |
( |
Examples
meta_f = function(z) {
x = 1
y = 2
crate(function() {
c(x, y, z)
}, x)
}
x = 100
y = 200
z = 300
f = meta_f(1)
f()
[Package mlr3misc version 0.15.1 Index]