I have the following (pointless) function, in R:
say <- function (string){
if(!exists("string")){
stop("no output string was specified")
}
cat(string)
}
Which is all very well at checking the string object actually exists. However, if an object of the same name is already floating about in the workspace, it’ll ignore the error even though that’s not defined in the function.
Can I make it so the exists() function only looks in the function-space for the object?
You’re looking for
missing. Others do something like this instead: