Skip to content
Prev 308835 / 398503 Next

Export summary from regression output

On 10/23/2012 5:59 AM, PIKAL Petr wrote:
Alternatively, if you don't care about the tabular nature of the 
coefficients table, you can just do:

mdl <- lm(Sepal.Width ~ Sepal.Length, data=iris)
write.table(capture.output(print(mdl)), file="")

That is, use capture.output on the print method and write that out. For 
this example, the file would look like

"x"
"1" ""
"2" "Call:"
"3" "lm(formula = Sepal.Width ~ Sepal.Length, data = iris)"
"4" ""
"5" "Coefficients:"
"6" " (Intercept)  Sepal.Length  "
"7" "     3.41895      -0.06188  "
"8" ""