[R] function parameters - testing

Larry Howe linux at comjet.com
Fri Jun 9 21:56:38 CEST 2006


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 print(is.null(x)) : Object "z" not found

exists gives TRUE, but then any other kind of test I try to run gives me an 
error. I need a test for existence that will work inside a function.

Larry Howe



More information about the R-help mailing list