EVOLUTION-MANAGER
Edit File: inject.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Inject objects in an R expression</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for inject {rlang}"><tr><td>inject {rlang}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Inject objects in an R expression</h2> <h3>Description</h3> <p><code>inject()</code> evaluates an expression with <a href="topic-inject.html">injection</a> support. There are three main usages: </p> <ul> <li> <p><a href="splice-operator.html">Splicing</a> lists of arguments in a function call. </p> </li> <li><p> Inline objects or other expressions in an expression with <code style="white-space: pre;">!!</code> and <code style="white-space: pre;">!!!</code>. For instance to create functions or formulas programmatically. </p> </li> <li><p> Pass arguments to NSE functions that <a href="topic-defuse.html">defuse</a> their arguments without injection support (see for instance <code><a href="defusing-advanced.html">enquo0()</a></code>). You can use <code>{{ arg }}</code> with functions documented to support quosures. Otherwise, use <code>!!enexpr(arg)</code>. </p> </li></ul> <h3>Usage</h3> <pre> inject(expr, env = caller_env()) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>expr</code></td> <td> <p>An argument to evaluate. This argument is immediately evaluated in <code>env</code> (the current environment by default) with injected objects and expressions.</p> </td></tr> <tr valign="top"><td><code>env</code></td> <td> <p>The environment in which to evaluate <code>expr</code>. Defaults to the current environment. For expert use only.</p> </td></tr> </table> <h3>Examples</h3> <pre> # inject() simply evaluates its argument with injection # support. These expressions are equivalent: 2 * 3 inject(2 * 3) inject(!!2 * !!3) # Injection with `!!` can be useful to insert objects or # expressions within other expressions, like formulas: lhs <- sym("foo") rhs <- sym("bar") inject(!!lhs ~ !!rhs + 10) # Injection with `!!!` splices lists of arguments in function # calls: args <- list(na.rm = TRUE, finite = 0.2) inject(mean(1:10, !!!args)) </pre> <hr /><div style="text-align: center;">[Package <em>rlang</em> version 1.0.6 <a href="00Index.html">Index</a>]</div> </body></html>