[R] Please, remind a function name

Vladimir Eremeev wl2776 at gmail.com
Tue May 22 18:20:09 CEST 2007

Sorry, I'm stuck. :)

I am writing a function, which would fit either one linear model or another
one, depending on its argument model.type.
And I don't want to use several if's, because R allows doing it with much
more beauty.

That is I am looking for prettier alternative to the following

AB2C<-function(a,b,model.type="S") { # or HK, and return NULL if this
argument has any other value
[ do some stuff]

  if(model.type=="S") model<-lm( [s.model formula] )
  else if (model.type == "HK") model<-lm([hk.model formula])
  else model<-NULL


I was looking at "switch", but didn't come to solution. Sorry <:)

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

More information about the R-help mailing list