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

parenvs

Given an environment or object, return an envlist of its parent environments.


Description

If e is not specified, it will start with environment from which the function was called.

Usage

parenvs(e = parent.frame(), all = FALSE)

Arguments

e

An environment or other object.

all

If FALSE (the default), stop at the global environment or the empty environment. If TRUE, print all parents, stopping only at the empty environment (which is the top-level environment).

Examples

# Print the current environment and its parents
parenvs()

# Print the parent environments of the load_all function
e <- parenvs(parenvs)
e

# Get all parent environments, going all the way to empty env
e <- parenvs(parenvs, TRUE)
e

# Print e with paths
print(e, path = TRUE)

# Print the first 6 environments in the envlist
e[1:6]

# Print just the parent environment of load_all.
# This is an envlist with one element.
e[1]

# Pull that environment out of the envlist and see what's in it.
e[[1]]
ls(e[[1]], all.names = TRUE)

pryr

Tools for Computing on the Language

v0.1.4
GPL-2
Authors
Hadley Wickham [aut, cre], R Core team [ctb] (Some code extracted from base R)
Initial release

We don't support your browser anymore

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