### Name: by ### Title: Apply a Function to a Data Frame split by Factors ### Aliases: by by.default by.data.frame print.by ### Keywords: iteration category ### ** Examples require(stats) attach(warpbreaks) by(warpbreaks[, 1:2], tension, summary) by(warpbreaks[, 1], list(wool = wool, tension = tension), summary) by(warpbreaks, tension, function(x) lm(breaks ~ wool, data = x)) ## now suppose we want to extract the coefficients by group tmp <- by(warpbreaks, tension, function(x) lm(breaks ~ wool, data = x)) sapply(tmp, coef) detach("warpbreaks")