EVOLUTION-MANAGER
Edit File: as_environment.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: Coerce to an environment</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 as_environment {rlang}"><tr><td>as_environment {rlang}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Coerce to an environment</h2> <h3>Description</h3> <p><code>as_environment()</code> coerces named vectors (including lists) to an environment. The names must be unique. If supplied an unnamed string, it returns the corresponding package environment (see <code><a href="search_envs.html">pkg_env()</a></code>). </p> <h3>Usage</h3> <pre> as_environment(x, parent = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>An object to coerce.</p> </td></tr> <tr valign="top"><td><code>parent</code></td> <td> <p>A parent environment, <code><a href="empty_env.html">empty_env()</a></code> by default. This argument is only used when <code>x</code> is data actually coerced to an environment (as opposed to data representing an environment, like <code>NULL</code> representing the empty environment).</p> </td></tr> </table> <h3>Details</h3> <p>If <code>x</code> is an environment and <code>parent</code> is not <code>NULL</code>, the environment is duplicated before being set a new parent. The return value is therefore a different environment than <code>x</code>. </p> <h3>Examples</h3> <pre> # Coerce a named vector to an environment: env <- as_environment(mtcars) # By default it gets the empty environment as parent: identical(env_parent(env), empty_env()) # With strings it is a handy shortcut for pkg_env(): as_environment("base") as_environment("rlang") # With NULL it returns the empty environment: as_environment(NULL) </pre> <hr /><div style="text-align: center;">[Package <em>rlang</em> version 1.0.6 <a href="00Index.html">Index</a>]</div> </body></html>