Skip to content

Instantly share code, notes, and snippets.

@sckott
Created November 29, 2012 00:32
Show Gist options
  • Save sckott/4165847 to your computer and use it in GitHub Desktop.
Save sckott/4165847 to your computer and use it in GitHub Desktop.
model to data.frame
#
library(plyr)
m1 <- lm(Petal.Length ~ Petal.Width, data=iris)
m2 <- lm(Petal.Length ~ Petal.Width + Species, data=iris)
tt <- function(x) {
temp <- data.frame(rnorm(1), summary(x)[4], summary(x)[8])
names(temp) <- c("model", "est", "se", "t", "p", "r2")
temp
}
out <- ldply(list(m1, m2), tt)
write.csv(out, "~/mydata.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment