I\'d like to check if some variable is defined in R - without getting an error. How can I do this?
My attempts (not successful):
> is.na(ooxx) Err
If you don't want to use quotes, you can use deparse(substitute()) trick which I found in the example section of ?substitute:
deparse(substitute())
?substitute
is.defined <- function(sym) { sym <- deparse(substitute(sym)) env <- parent.frame() exists(sym, env) } is.defined(a) # FALSE a <- 10 is.defined(a) # TRUE