Viechtbauer Wolfgang (STAT)
2010-Apr-19 11:51 UTC
[R] Writing methods for existing generic function
Dear All, Suppose I want to write a method for the generic function confint():> args(confint)function (object, parm, level = 0.95, ...) So, it looks like the second and third argument have been predefined in the generic function. Suppose one or several of the predefined arguments don't apply or fit (in some sense) with the design of the rest of the package. What should one do? I see several options: 1) Write a new generic function. 2) Rewrite the package (if possible) so that the arguments of the existing generic function do apply (in some sense). 3) Write a method for the existing generic function, adding the predefined arguments to the method call, but just ignore some/all of them in whatever is being done inside of the method function. Are there any other options? Is there some recommended practice for this? Thanks in advance for any feedback! Best, -- Wolfgang Viechtbauer http://www.wvbauer.com/ Department of Methodology and Statistics Tel: +31 (43) 388-2277 School for Public Health and Primary Care Office Location: Maastricht University, P.O. Box 616 Room B2.01 (second floor) 6200 MD Maastricht, The Netherlands Debyeplein 1 (Randwyck)
On 19.04.2010 13:51, Viechtbauer Wolfgang (STAT) wrote:> Dear All, > > Suppose I want to write a method for the generic function confint(): > >> args(confint) > function (object, parm, level = 0.95, ...) > > So, it looks like the secondreally??? > and third argument have been predefined in the generic function. Suppose one or several of the predefined arguments don't apply or fit (in some sense) with the design of the rest of the package. What should one do? I see several options:> > 1) Write a new generic function. > 2) Rewrite the package (if possible) so that the arguments of the existing generic function do apply (in some sense). > 3) Write a method for the existing generic function, adding the predefined arguments to the method call, but just ignore some/all of them in whatever is being done inside of the method function.I'd go with 3 if it fits at least somwhow to the aim of the original generic. Uwe Ligges> > Are there any other options? Is there some recommended practice for this? > > Thanks in advance for any feedback! > > Best, > > -- > Wolfgang Viechtbauer http://www.wvbauer.com/ > Department of Methodology and Statistics Tel: +31 (43) 388-2277 > School for Public Health and Primary Care Office Location: > Maastricht University, P.O. Box 616 Room B2.01 (second floor) > 6200 MD Maastricht, The Netherlands Debyeplein 1 (Randwyck) > > ______________________________________________ > R-help at 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.