Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

crate

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 = .GlobalEnv)

Arguments

.fn

(function())
function to crate

...

(any)
The objects, which should be visible inside .fn.

.parent

(environment)
Parent environment to look up names. Default so the global environment.

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()

mlr3misc

Helper Functions for 'mlr3'

v0.10.0
LGPL-3
Authors
Michel Lang [cre, aut] (<https://orcid.org/0000-0001-9754-0393>), Patrick Schratz [aut] (<https://orcid.org/0000-0003-0748-6624>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.