Learn R Programming

envnames

R package to retrieve the name of user-defined environments and of function execution environments.

Description

The main goal of this package is to overcome the limitation of the built-in environmentName() function from the base package which does not return the name of an environment unless it is a package, a namespace or a system environment (e.g. the global environment, the base environment, the empty environment).

The envnames package solves this problem by creating a lookup table that maps environment names to their memory addresses. Using this lookup table, it is possible to retrieve the name of any environment where an object resides, be it a package, namespace, system environment, user-defined environment, or function execution environment.

See the following post as motivation for creating this package: https://stat.ethz.ch/pipermail/r-help/2010-July/245646.html

Copy Link

Version

Install

install.packages('envnames')

Monthly Downloads

174

Version

0.4.1

License

GPL

Issues

Pull Requests

Stars

Forks

Maintainer

Daniel Mastropietro

Last Published

December 8th, 2020

Functions in envnames (0.4.1)

check_environment

Check whether a string corresponds to the name of an environment
collapse_root_and_member

Put together a root name with a member name
address

Call the C function address() that retrieves the memory address of an R object
crawl_envs

Crawl environments in search of user environments
clean_up_matching_environments

Clean up the list of environments matching a memory address in an environment map.
crawl_envs_in_env

Crawl an environment in search of user environments
check_object_exists

Check if an object exists in a given environment
environment_name

Retrieve the name of an environment
destandardize_env_name

De-standardize the name of an environment
check_object_with_path

Check if an object name contains a valid environment path
get_fun_calling_chain

Return the chain of calling functions
get_env_names

Create a lookup table with address-name pairs of environments
get_envs_in_env

Find user environments inside another user environment
get_fun_calling

Return the name of a calling function with its context or path
obj_find

Find an object in the workspace including user-defined environments
get_fun_env

Return the execution environment of a function
get_user_environment_names_in_search_path

Look for user environments defined inside any of the system/package environments of the search path
get_environment_name

Get the name of an environment when the address-name lookup table has not yet been constructed
get_user_environments_in_user_envs_recursively

Get the user environments defined recursively within the given user environments
get_obj_value

Return the value of the object at a given parent generation leading to the specified object
get_fun_name

Return the name of the current function or a calling function in the chain
extract_root_and_last_member

Extract the last member in a string representing an object
envnames-package

Track user-defined environment names
get_namespace_names

Return the names that can be used to load all the namespace environments in the search() list
get_namespace_addresses

Return the memory address of namespace environments in the search() list
get_obj_name

Return the name of an object at a given parent generation from an environment
testenv

Environment used in testing the package
get_obj_addresses_from_obj_names

Get the object addresses given their object names
standardize_env_name

Standardize the name of a named environment
unlist_with_names

Call unlist and preserve the names
is_null_or_na

Check whether an object is NULL or NA.
get_obj_address

Return the memory address of an object
is_string

Check whether an object is a string.
parse_memory_address

Parse a string that represents a memory address
get_searchpath_environment_addresses

Return the system and package environments in the search path
reset_option_warn

Resets the "warn" option to the value stored in the hidden variable .option_warn (set in global_definitions.r to the original value of the "warn" option when the package is loaded).
set_option_warn_to_nowarning

Set the "warn" options to -1 to avoid warning messages. The hidden variable .option_warn defined in global_definitions.r has already been set to the original value of the "warn" option, at the moment when the package is loaded, so that we can reset it later.
get_user_environment_names_in_env

Look for user environments defined inside an environment
is_memory_address

Check whether a string is a memory address
is_logical

Check whether an object contains a valid logical value
get_objects_in_package

Get the objects defined in a given package's namespace