Created
October 7, 2014 15:30
-
-
Save mikelove/3816eac0e05702e2ee08 to your computer and use it in GitHub Desktop.
broom and ggplot2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(broom) | |
library(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() |
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
Nice! With dplyr/magrittr it can be even more space-efficient:
(dplyr also makes it easier to perform regressions on subgroups or replications).