crawl_envs: Crawl environments in search of user environments

Description Usage Arguments Details Value

View source: R/functions.r

Description

Function that crawls a set of environments to search for user environments defined within each of them.

Usage

1
crawl_envs(env_names, path, path_to_envs_found, rootenvir = NULL)

Arguments

env_names

array with the environment names where the search for environments is wished (careful: should not contain the environment *objects* but their *names*!).

path

array with user environment names leading to the current set of environments listed in env_names. Ex: c("env_of_envs", "env11") which means that the the environments listed in env_names exist in environment env_of_envs$env11.

path_to_envs_found

array of user environment names found so far including their path where the path is allowed to include ONLY user environments. (e.g. an element of the path_to_envs_found array could be "env1$env2$env", but NOT "R_GlobalEnv$env1$env2", because "R_GobalEnv" is the name of a system environment, NOT a user environment). The first time this function is called it should contain the empty array.

rootenvir

environment used as starting point for the user environment search process. If NULL, the environment is taken from the names attribute of the env_names parameter.

Details

This function crawls the user environments defined in the rootenvir environment and any user environments within those user environments until no user environment has been left without visit, making up a tree of nested user environments. The path to each user environment found is stored using the $ notation as in env1$env12$envx.

Instead of setting the rootenvir parameter to the root environment where the search should start, a similar result is obtained by setting the path variable to the environment chain leading to the environments passed in env_names, as in e.g. c("env_of_envs", "env11"). The difference is that such environment will appear as part of the paths to the environments passed, and in addition, it is assumed that such environment is an actual environment.

Value

An array containing the path to each user environment found inside the rootenvir environment and all the nested user environments found within each of them. This array is concatenated to whatever paths are already listed in the path_to_envs_found parameter passed to the function.


envnames documentation built on Dec. 8, 2020, 9:07 a.m.