Instantly share code, notes, and snippets.

Embed
What would you like to do?
broom and ggplot2
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()
@dgrtwo

This comment has been minimized.

Show comment
Hide comment
@dgrtwo

dgrtwo Oct 7, 2014

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

library(dplyr)
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 7, 2014

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

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

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

@dgrtwo

This comment has been minimized.

Show comment
Hide comment
@dgrtwo

dgrtwo Oct 19, 2014

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

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