lazy_

0th

Percentile

Capture expression for later lazy evaluation.

lazy() uses non-standard evaluation to turn promises into lazy objects; lazy_() does standard evaluation and is suitable for programming.

Usage
lazy_(expr, env)
lazy(expr, env = parent.frame(), .follow_symbols = TRUE)
Arguments
expr
Expression to capture. For lazy_ must be a name or a call.
env
Environment in which to evaluate expr.
.follow_symbols
If TRUE, the default, follows promises across function calls. See vignette("chained-promises") for details.
Details

Use lazy() like you'd use substitute() to capture an unevaluated promise. Compared to substitute() it also captures the environment associated with the promise, so that you can correctly replay it in the future.

Aliases
  • lazy
  • lazy_
Examples
library(lazyeval) lazy_(quote(a + x), globalenv()) # Lazy is designed to be used inside a function - you should # give it the name of a function argument (a promise) f <- function(x = b - a) { lazy(x) } f() f(a + b / c) # Lazy also works when called from the global environment. This makes # easy to play with interactively. lazy(a + b / c) # By default, lazy will climb all the way back to the initial promise # This is handy if you have if you have nested functions: g <- function(y) f(y) h <- function(z) g(z) f(a + b) g(a + b) h(a + b) # To avoid this behavour, set .follow_symbols = FALSE # See vignette("chained-promises") for details
Documentation reproduced from package lazyeval, version 0.2.0, License: GPL-3

Community examples

Looks like there are no examples yet.