On 6/06/2008, at 12:57 PM, Erik Iverson wrote:
Note the difference between
test <- function(a) {
exists("a", mode = "symbol")
}
test()
and
test2 <- function(a) {
exists("a", mode = "numeric") #say
}
test2()
and then note that the default mode argument to exists is "any".
Basically, I think, you're saying that a formal argument exists ``as
a symbol''
(even if the object named doesn't exist) and that's why exists("a")
returns TRUE
in these circumstances.
I'm still a bit puzzled, but:
Although test() gives TRUE and test2() gives FALSE,
both test(a) and test2(a) throw an error:
Error in exists("a", mode = "symbol") : object "a" not found
and
Error in exists("a", mode = "numeric") : object "a" not found
whereas if I don't say anything about the mode, as in
test3 <- function(a) {
exists("a")
}
then test3(a) evaluates to TRUE (even though there is no ``a''
anywhere in
the search path.
Also with a redundant specification of the mode, as in
test4 <- function(a){
exists("a",mode="any")
}
one gets test4(a) to be TRUE (no error thrown).
I don't see the pattern. But it's probably not worth wasting time on.
cheers,
Rolf Turner
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.