# NOT RUN {
library(dplyr)
regressions <- mtcars %>%
group_by(cyl) %>%
do(mod = lm(mpg ~ wt, .))
regressions
regressions %>% tidy(mod)
regressions %>% augment(mod)
regressions %>% glance(mod)
# we can provide additional arguments to the tidying function
regressions %>% tidy(mod, conf.int = TRUE)
# we can also include the original dataset as a "data" argument
# to augment:
regressions <- mtcars %>%
group_by(cyl) %>%
do(mod = lm(mpg ~ wt, .), original = (.))
# this allows all the original columns to be included:
regressions %>% augment(mod) # doesn't include all original
regressions %>% augment(mod, data = original) # includes all original
# }
Run the code above in your browser using DataLab