check_object_with_path {envnames} | R Documentation |
Check if an object name contains a valid environment path
Description
Check if a string may represent a valid object name with full environment path to the object
as in globalenv()$env$x
. The string should not end with ]
or )
because
that makes the whole expression an invalid name and therefore it should not be considered as a name
(e.g. globalenv()$v[1]
refers to element 1 of array v and such thing is not the name of an object).
Usage
check_object_with_path(x, checkenv = FALSE, envir = NULL)
Arguments
x |
string to be checked. |
checkenv |
flag indicating whether the environment path should be checked for valid environment as well. Defaults to FALSE. |
envir |
environment where |
Details
Optionally a check of whether the path points to a valid environment inside a given environment is performed by calling .
Value
A list containing the following elements:
When checkenv=FALSE
:
ok
boolean indicating whether the string may be a valid object namepath
path to the namename
the name itself with no path.
When checkenv=TRUE
and when the string given in x
is deemed to be a possible valid object,
the following additional elements:
env_found
flag indicating whether the string indicating the path to the object name referenced byx
is the name of an existing environment in the workspaceenv_name
the name of the environment (after stripping out any system environments such as globalenv(), baseenv() or a package environment) (for instance "globalenv()$env$env1" is returned as "env$env1"), or NULL if no environment is found corresponding to the path given inx
.