There are some nice exmaples of how to broom up some basic results from lm here: https://cran.r-project.org/web/packages/broom/vignettes/broom_and_dplyr.html
The next logical step might be to plot some of the results since comparing slopes of regressions can be useful. The mtcars dataset is useful here:
library(tidyverse)
## ── Attaching packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 2.2.1.9000 ✔ purrr 0.2.4
## ✔ tibble 1.4.2 ✔ dplyr 0.7.4
## ✔ tidyr 0.7.2 ✔ stringr 1.2.0
## ✔ readr 1.1.1 ✔ forcats 0.2.0
## ── Conflicts ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(broom)
theme_set(theme_bw())
ggplot(mtcars, aes(x = disp, y = mpg)) + geom_point() +
geom_smooth(method = "lm") +
facet_grid(~ cyl)
Then do the lm for each of those three plots using group_by instead of the facet_grid, organise the results with tidy, and then plot the slope (estimate) with error bars (std.error):
mtcars %>% group_by(cyl) %>% do(tidy(lm(mpg ~ disp, data=.))) %>% subset(., term == "disp") %>%
ggplot(., aes(x = cyl, y = estimate)) +
geom_point() +
geom_errorbar(aes(ymin = estimate - std.error, ymax = estimate + std.error)) +
labs(x = "Number of cylinders", y = "Slope of mpg~disp regression with standard error")