Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
broom and ggplot2
tidyfit <- tidy(fit)
tidyfit$xmin <- with(tidyfit, estimate - stderror)
tidyfit$xmax <- with(tidyfit, estimate + stderror)
ggplot(tidyfit, aes(x=estimate,y=term,xmin=xmin,xmax=xmax,height=0)) +
geom_point() + geom_vline(xintercept=0) + geom_errorbarh()

dgrtwo commented Oct 7, 2014

Nice! With dplyr/magrittr it can be even more space-efficient:

tidyfit <- fit %>% tidy() %>%
    mutate(xmin = estimate - stderror, xmax = estimate + stderror)

(dplyr also makes it easier to perform regressions on subgroups or replications).

dgrtwo commented Oct 19, 2014

Please note that as of version 0.3, the stderror column has been changed to std.error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment