I would like to wrap R::base
function exists
into a wrapper function to make it more C-based and variadic in nature.
### current examples of `exists` usage
if(!exists(".humanVerse")) { initMemory(); }
#############################
if(!exists("path", .GlobalEnv$.humanVerse) || purge.memory)
{
### do something here
}
#############################
if(exists(save.key, .GlobalEnv$.humanVerse[["colors"]][["dataframes"]]))
{
return( .GlobalEnv$.humanVerse[["colors"]][["dataframes"]][[save.key]] );
}
The above examples work fine, in the order applied. But if I wanted to write a function to capture or trap the non-existent key, it will cause a problem.
exists("not.created");
whereas
checkExists = function(x)
{
exists(x);
}
checkExists(not.created);
throws an object not found error. Of course, I recognize that the "string" form of "not.created" is different than a variadic form.
I am looking for a way for the checkExists
function to work.
The x
in exists
looks for a name, a character vector. What if I want to checkExists
on an object, not a character? That is the essence of the variadic question.
Maybe I am merely asking how to capture the character name of the object? I don't know. R::base
logic contorts my logic from time to time.