Larry Howe wrote:
Hello,
I am trying to test a function argument to see if it is or is not a useful
number. However I cannot seem to find a test that works. For example
f = function(x) {
+ print(exists(x))
+ print(is.null(x))
+ }
rm(x)
f(z)
[1] TRUE
Error in
x exists within the function f so the first print is TRUE;
however, exists does not try to evaluate it. is.null
does try to evaluate it and so at that point it discovers
the error.
Perhaps you want this:
f - function(x) if (exists(deparse(substitute(x print(is.null(x))
else print(none)
if
On Friday June 9 2006 16:06, Sundar Dorai-Raj wrote:
Larry Howe wrote:
This works because x exists in the function f. Perhaps you want this
instead?
f - function(x) {
print(deparse(substitute(x)))
print(exists(deparse(substitute(x
print(is.null(x))
invisible()
}
Your