lm_summary(model)

Extract a clean, tidy data frame from a fitted lm object: coefficients, standard errors, t-values, p-values and significance stars.

statisticsutility
Args:model — fitted lm object
lm_summary <- function(model) {
  s <- summary(model)$coefficients
  df <- as.data.frame(s)
  colnames(df) <- c("Estimate", "SE", "t", "p")
  df$stars <- cut(df$p, c(-Inf, 0.001, 0.01, 0.05, 0.1, Inf),
                  labels = c("***", "**", "*", ".", ""))
  df$term <- rownames(df)
  rownames(df) <- NULL
  df[, c("term", "Estimate", "SE", "t", "p", "stars")]
}

# Example
m <- lm(Sepal.Length ~ Sepal.Width + Species, data = iris)
lm_summary(m)