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

env_name

Label of an environment


Description

Special environments like the global environment have their own names. env_name() returns:

  • "global" for the global environment.

  • "empty" for the empty environment.

  • "base" for the base package environment (the last environment on the search path).

  • "namespace:pkg" if env is the namespace of the package "pkg".

  • The name attribute of env if it exists. This is how the package environments and the imports environments store their names. The name of package environments is typically "package:pkg".

  • The empty string "" otherwise.

env_label() is exactly like env_name() but returns the memory address of anonymous environments as fallback.

Usage

env_name(env)

env_label(env)

Arguments

env

An environment.

Examples

# Some environments have specific names:
env_name(global_env())
env_name(ns_env("rlang"))

# Anonymous environments don't have names but are labelled by their
# address in memory:
env_name(env())
env_label(env())

rlang

Functions for Base Types and Core R and 'Tidyverse' Features

v0.4.11
MIT + file LICENSE
Authors
Lionel Henry [aut, cre], Hadley Wickham [aut], mikefc [cph] (Hash implementation based on Mike's xxhashlite), Yann Collet [cph] (Author of the embedded xxHash library), RStudio [cph]
Initial release

We don't support your browser anymore

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