# NOT RUN {
my_tidy <- function(x, exponentiate = FALSE, conf.level = 0.95, ...) {
tidy <-
dplyr::bind_cols(
broom::tidy(x, conf.int = FALSE),
# calculate the confidence intervals, and save them in a tibble
stats::confint.default(x) %>%
tibble::as_tibble() %>%
rlang::set_names(c("conf.low", "conf.high"))
)
# exponentiating, if requested
if (exponentiate == TRUE)
tidy <- dplyr::mutate_at(vars(estimate, conf.low, conf.high), exp)
tidy
}
lm(age ~ grade + response, trial) %>%
my_tidy()
# }
Run the code above in your browser using DataLab