# example 1
mtcars.list <- split(mtcars, mtcars$cyl)
mylm <- function(x, form, me) lm(form, x, method = me)
lm.list1 <- lapply(mtcars.list, mylm, mpg~hp+wt, "qr")
# example 2 - use package plyr - all ply functions have consistent syntax
library(plyr)
lm.list2 <- dlply(mtcars, .(cyl), function(x) {
lm(mpg~hp+wt, x)
})