Skip to content
Prev 76139 / 398502 Next

help on retrieving output from by( ) for regression

Also, looking at the last example in ?by would be helpful:

attach(warpbreaks)
tmp <- by(warpbreaks, tension, function(x) lm(breaks ~ wool, data = x))

# To get coefficients:
sapply(tmp, coef)

# To get residuals:
sapply(tmp, resid)

# To get the model matrix:
sapply(tmp, model.matrix)



To get the summary() output, I suspect that using:

  lapply(tmp, summary)

would yield more familiar output as compared to using:

  sapply(tmp, summary)

The output from the latter might require a bit more "navigation" through
the resultant matrix, depending upon how the output is to be ultimately
used.

HTH,

Marc Schwartz
On Thu, 2005-08-25 at 14:57 +0200, TEMPL Matthias wrote: