[R] Please, remind a function name

Vladimir Eremeev wl2776 at gmail.com
Wed May 23 10:59:38 CEST 2007


Great!
I was thinking about adding such a feature in the future.


Gabor Grothendieck wrote:
> 
> Note that a significant difference between the two solutions is that
> the OO solution allows new methods corresponding to "method="
> to be added without changing the function holding the statements.
> 
>> My solution (after a cup of coffee :) ):
>>
>> model.formula<-switch(model.type,S=[s-model formula],HK=[hk-model
>> formula])
>> model<-lm(model.formula)
>>
>> Gabor Grothendieck wrote:
>> >
>> > You could use the class dispatching mechanism:
>> >
>> >
>> > mymodel <- function(a, b, method = "S") {
>> >       .Class <- method
>> >       NextMethod("mymodel")
>> > }
>> >
>> > mymodel.S <- function(a, b, method = "S") cat("S:", a, b, method, "\n")
>> > mymodel.HK <- function(a, b, method = "S") cat("HK:", a, b, method,
>> "\n")
>> >
>> > mymodel(1:3, 1:4)
>> > mymodel(1:3, 1:4, "S")
>> > mymodel(1:3, 1:4, "HK")
>> >
> 

-- 
View this message in context: http://www.nabble.com/Please%2C-remind-a-function-name-tf3797444.html#a10759959
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list