Skip to content
Prev 164811 / 398503 Next

Noobie question, regression across levels

RichardLang wrote:
You can check out lmList function in the nlme package, or more crudely:

lmfun <- function(d) { lm(y~x,data=d) }
myLmList <- lapply(split(mydata,splitfactor),lmfun)

even more compactly/confusingly:

myLmList <- lapply(split(mydata,splitfactor),lm,formula=y~x)

  good luck
   Ben Bolker