EVOLUTION-MANAGER
Edit File: env_parent.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: Get parent environments</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 env_parent {rlang}"><tr><td>env_parent {rlang}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Get parent environments</h2> <h3>Description</h3> <ul> <li> <p><code>env_parent()</code> returns the parent environment of <code>env</code> if called with <code>n = 1</code>, the grandparent with <code>n = 2</code>, etc. </p> </li> <li> <p><code>env_tail()</code> searches through the parents and returns the one which has <code><a href="empty_env.html">empty_env()</a></code> as parent. </p> </li> <li> <p><code>env_parents()</code> returns the list of all parents, including the empty environment. This list is named using <code><a href="env_name.html">env_name()</a></code>. </p> </li></ul> <p>See the section on <em>inheritance</em> in <code><a href="env.html">env()</a></code>'s documentation. </p> <h3>Usage</h3> <pre> env_parent(env = caller_env(), n = 1) env_tail(env = caller_env(), last = global_env()) env_parents(env = caller_env(), last = global_env()) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>env</code></td> <td> <p>An environment.</p> </td></tr> <tr valign="top"><td><code>n</code></td> <td> <p>The number of generations to go up.</p> </td></tr> <tr valign="top"><td><code>last</code></td> <td> <p>The environment at which to stop. Defaults to the global environment. The empty environment is always a stopping condition so it is safe to leave the default even when taking the tail or the parents of an environment on the search path. </p> <p><code>env_tail()</code> returns the environment which has <code>last</code> as parent and <code>env_parents()</code> returns the list of environments up to <code>last</code>.</p> </td></tr> </table> <h3>Value</h3> <p>An environment for <code>env_parent()</code> and <code>env_tail()</code>, a list of environments for <code>env_parents()</code>. </p> <h3>Examples</h3> <pre> # Get the parent environment with env_parent(): env_parent(global_env()) # Or the tail environment with env_tail(): env_tail(global_env()) # By default, env_parent() returns the parent environment of the # current evaluation frame. If called at top-level (the global # frame), the following two expressions are equivalent: env_parent() env_parent(base_env()) # This default is more handy when called within a function. In this # case, the enclosure environment of the function is returned # (since it is the parent of the evaluation frame): enclos_env <- env() fn <- set_env(function() env_parent(), enclos_env) identical(enclos_env, fn()) </pre> <hr /><div style="text-align: center;">[Package <em>rlang</em> version 1.0.6 <a href="00Index.html">Index</a>]</div> </body></html>