[R] Testing for existence inside a function

From: Talbot Katz <topkatz_at_msn.com>
Date: Tue, 15 May 2007 10:48:31 -0400


I'm having trouble testing for existence of an object inside a function.

Suppose I have a function:


and I call it with argument y:


I'd like to check inside the function whether argument y exists. Is this possible, or do I have to either check outside the function or pass the name of the argument as a separate argument?

If I do exists(x) or exists(eval(x)) inside the function and y does not exist, it generates an error message. If I do exists("x") it says that x exists even if y does not. If I had a separate argument to hold the text string "y" then I could check that. But is it possible to check the existence of the argument inside the function without passing its name as a separate argument?


R-help_at_stat.math.ethz.ch 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. Received on Tue 15 May 2007 - 14:56:19 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 15 May 2007 - 20:33:41 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.