I'm trying to build a pair of (S3) methods, a "formula" method and a "default" method. The methods have a "data" argument. If the variables in question cannot be found in "data" then they should be sought in the global environment.
My problem is that the generic dispatches on its first argument, which may be a formula (in which case it of course dispatches to the formula method) or the first of the variables. If this variable exists in the global environment then all is well. But if it doesn't exist there, then the generic falls over with an error of the form "object 'x' not found" --- because there isn't anything to dispatch on. I'd *like* to be able to tell the generic that if "x" is not found then it should dispatch to the default method (which will, if the call is sensible, find "x" in "data"). Is there any way to tell the generic to do this? Or is there any other way out of this dilemma? (Other than "Give up and go to the pub", which I cannot currently do since Auckland is in Level 4 lockdown. :-) ) Thanks for any enlightenment. cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.