• env_parent() returns the parent environment of env if called with n = 1, the grandparent with n = 2, etc.

• env_tail() searches through the parents and returns the one which has empty_env() as parent.

• env_parents() returns the list of all parents, including the empty environment.

See the section on inheritance in env()'s documentation.

env_parent(env = caller_env(), n = 1)

env_tail(env = caller_env())

env_parents(env = caller_env())

## Arguments

env An environment or an object bundling an environment, e.g. a formula, quosure or closure. The number of generations to go up.

## Value

An environment for env_parent() and env_tail(), a list of environments for env_parents().

## Examples

# Get the parent environment with env_parent():
env_parent(global_env())#> <environment: package:rlang>
#> attr(,"name")
#> [1] "package:rlang"
#> attr(,"path")
identical(enclos_env, fn())#> [1] TRUE