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).
check_object_with_path(x, checkenv = FALSE, envir = NULL)
string to be checked.
flag indicating whether the environment path should be checked for valid environment as well. Defaults to FALSE.
environment where x
should be evaluated when also checking the environment.
Only used when checkenv=TRUE
.
A list containing the following elements:
When checkenv=FALSE
:
ok
boolean indicating whether the string may be a valid object name
path
path to the name
name
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 by x
is the name of an existing environment in the workspace
env_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 in x
.
Optionally a check of whether the path points to a valid environment inside a given environment
is performed by calling .