broom v0.5.0

0

Monthly downloads

0th

Percentile

Convert Statistical Analysis Objects into Tidy Tibbles

Summarizes key information about statistical objects in tidy tibbles. This makes it easy to report results, create plots and consistently work with large numbers of models at once. Broom provides three verbs that each provide different types of information about a model. tidy() summarizes information about model components such as coefficients of a regression. glance() reports information about an entire model, such as goodness of fit measures like AIC and BIC. augment() adds information about individual observations to a dataset, such as fitted values or influence measures.

Readme

broom

CRAN status Travis-CI Build Status AppVeyor Build Status Coverage Status

Overview

broom summarizes key information about models in tidy tibble()s. broom provides three verbs to make it convenient to interact with model objects:

  • tidy() summarizes information about model components
  • glance() reports information about the entire model
  • augment() adds informations about observations to a dataset

For a detailed introduction, please see vignette("broom").

broom tidies 100+ models from popular modelling packages and almost all of the model objects in the stats package that comes with base R. vignette("available-methods") lists method availabilty.

If you aren't familiar with tidy data structures and want to know how they can make your life easier, we highly recommend reading Hadley Wickham's Tidy Data.

Installation

# we recommend installing the entire tidyverse, which includes broom:
install.packages("tidyverse")

# alternatively, to install just broom:
install.packages("broom")

# to get the development version from GitHub:
install.packages("devtools")
devtools::install_github("tidyverse/broom")

If you find a bug, please file a minimal reproducible example in the issues.

Usage

tidy() produces a tibble() where each row contains information about an important component of the model. For regression models, this often corresponds to regression coefficients. This is can be useful if you want to inspect a model or create custom visualizations.

library(broom)

fit <- lm(Sepal.Width ~ Petal.Length + Petal.Width, iris)
tidy(fit)
#> # A tibble: 3 x 5
#>   term         estimate std.error statistic  p.value
#>   <chr>           <dbl>     <dbl>     <dbl>    <dbl>
#> 1 (Intercept)     3.59     0.0937     38.3  2.51e-78
#> 2 Petal.Length   -0.257    0.0669     -3.84 1.80e- 4
#> 3 Petal.Width     0.364    0.155       2.35 2.01e- 2

glance() returns a tibble with exactly one row of goodness of fitness measures and related statistics. This is useful to check for model misspecification and to compare many models.

glance(fit)
#> # A tibble: 1 x 11
#>   r.squared adj.r.squared sigma statistic p.value    df logLik   AIC   BIC
#> *     <dbl>         <dbl> <dbl>     <dbl>   <dbl> <int>  <dbl> <dbl> <dbl>
#> 1     0.213         0.202 0.389      19.9 2.24e-8     3  -69.8  148.  160.
#> # ... with 2 more variables: deviance <dbl>, df.residual <int>

augment adds columns to a dataset, containing information such as fitted values, residuals or cluster assignments. All columns added to a dataset have . prefix to prevent existing columns from being overwritten.

augment(fit, data = iris)
#> # A tibble: 150 x 12
#>    Sepal.Length Sepal.Width Petal.Length Petal.Width Species .fitted
#>  *        <dbl>       <dbl>        <dbl>       <dbl> <fct>     <dbl>
#>  1          5.1         3.5          1.4         0.2 setosa     3.30
#>  2          4.9         3            1.4         0.2 setosa     3.30
#>  3          4.7         3.2          1.3         0.2 setosa     3.33
#>  4          4.6         3.1          1.5         0.2 setosa     3.27
#>  5          5           3.6          1.4         0.2 setosa     3.30
#>  6          5.4         3.9          1.7         0.4 setosa     3.30
#>  7          4.6         3.4          1.4         0.3 setosa     3.34
#>  8          5           3.4          1.5         0.2 setosa     3.27
#>  9          4.4         2.9          1.4         0.2 setosa     3.30
#> 10          4.9         3.1          1.5         0.1 setosa     3.24
#> # ... with 140 more rows, and 6 more variables: .se.fit <dbl>,
#> #   .resid <dbl>, .hat <dbl>, .sigma <dbl>, .cooksd <dbl>,
#> #   .std.resid <dbl>

Contributing

We welcome contributions of all types!

If you have never made a pull request to an R package before, broom is an excellent place to start. Find an issue with the Beginner Friendly tag and comment that you'd like to take it on and we'll help you get started.

We encourage typo corrections, bug reports, bug fixes and feature requests. Feedback on the clarity of the documentation is especially valuable.

If you are interested in adding new tidiers methods to broom, please read vignette("adding-tidiers").

We have a Contributor Code of Conduct. By participating in broom you agree to abide by its terms.

Functions in broom

Name Description
augment.ivreg Augment data with information from a(n) ivreg object
durbinWatsonTest_tidiers Tidy/glance a(n) durbinWatsonTest object
glance.betareg Glance at a(n) betareg object
glance.orcutt Glance at a(n) orcutt object
augment.lm Augment data with information from a(n) lm object
emmeans_tidiers Tidy estimated marginal means (least-squares means) objects from the emmeans and lsmeans packages
augment.stl Augment data with information from a(n) stl object
augment.speedlm Augment data with information from a(n) speedlm object
glance.biglm Glance at a(n) biglm object
glance.plm Glance at a(n) plm object
glance.speedlm Glance at a(n) speedlm object
augment.prcomp Augment data with information from a(n) prcomp object
broom Convert Statistical Objects into Tidy Tibbles
augment.poLCA Augment data with information from a(n) poLCA object
glance.survdiff Glance at a(n) survdiff object
finish_glance Add logLik, AIC, BIC, and other common measurements to a glance of a prediction
augment.rqs Augment data with information from a(n) rqs object
tidy.geeglm Tidy a(n) geeglm object
tidy.Mclust Tidy a(n) Mclust object
column_glossary Allowed column names in tidied tibbles
tidy Turn a model object into a tidy tibble
fix_data_frame Ensure an object is a data frame, with rownames moved into a column
glance.Arima Glance at a(n) Arima object
glance Construct a single row summary "glance" of a model, fit, or other object
augment.smooth.spline Tidy a(n) smooth.spline object
glance.glmRob Glance at a(n) glmRob object
glance.binDesign Glance at a(n) binDesign object
glance.gmm Glance at a(n) gmm object
glance.glmnet Glance at a(n) glmnet object
glance.ivreg Glance at a(n) ivreg object
glance.cch Glance at a(n) cch object
glance.coxph Glance at a(n) coxph object
glance.cv.glmnet Glance at a(n) cv.glmnet object
glance.felm Glance at a(n) felm object
glance.aareg Glance at a(n) aareg object
tidy.aov Tidy a(n) aov object
glance.kmeans Glance at a(n) kmeans object
glance.lavaan Glance at a(n) lavaan object
augment.rlm Augment a(n) rlm object
tidy.aovlist Tidy a(n) aovlist object
glance.fitdistr Glance at a(n) fitdistr object
glance.nlrq Glance at a(n) nlrq object
glance.pyears Glance at a(n) pyears object
augment.survreg Augment data with information from a(n) survreg object
glance.rq Glance at a(n) rq object
glance.smooth.spline Tidy a(n) smooth.spine object
augment_columns add fitted values, residuals, and other common outputs to an augment call
confint_tidy Calculate confidence interval as a tidy data frame
sp_tidiers Tidy a(n) SpatialPolygonsDataFrame object
glance.lmodel2 Glance at a(n) lmodel2 object
glance.mjoint Glance at a(n) mjoint object
glance.ridgelm Glance at a(n) ridgelm object
tidy.betareg Tidy a(n) betareg object
tidy.Kendall Tidy a(n) Kendall object
tidy.Gam Tidy a(n) Gam object
sparse_tidiers Tidy a sparseMatrix object from the Matrix package
glance.rlm Glance at a(n) rlm object
data.frame_tidiers Tidiers for data.frame objects
insert_NAs insert a row of NAs into a data frame wherever another data frame has NAs
augment.rq Augment data with information from a(n) rq object
list_tidiers Tidying methods for lists / returned values that are not S3 objects
glance.Gam Glance at a(n) Gam object
tidy.gmm Tidy a(n) gmm object
null_tidiers Tidiers for NULL inputs
glance.Mclust Glance at a(n) Mclust object
tidy.htest Tidy/glance a(n) htest object
glance.garch Tidy a(n) garch object
glance.glm Glance at a(n) glm object
lme4_tidiers Tidying methods for mixed effects models
tidy.lmRob Tidy a(n) lmRob object
tidy.biglm Tidy a(n) biglm object
glance.factanal Glance at a(n) factanal object
glance.nls Glance at a(n) nls object
tidy.polr Tidying methods for ordinal logistic regression models
matrix_tidiers Tidiers for matrix objects
rowwise_df_tidiers Tidying methods for rowwise_dfs from dplyr, for tidying each row and recombining the results
glance.lm Glance at a(n) lm object
tidy.factanal Tidy a(n) factanal object
rstanarm_tidiers Tidying methods for an rstanarm model
tidy.felm Tidy a(n) felm object
tidy.lmodel2 Tidy a(n) lmodel2 object
tidy.multinom Tidying methods for multinomial logistic regression models
tidy.muhaz Tidy a(n) muhaz object
tidy.rqs Tidy a(n) rqs object
tidy.survfit Tidy a(n) survfit object
tidy.spec Tidy a(n) spec object
tidy.glmRob Tidy a(n) glmRob object
tidy.acf Tidy a(n) acf object
glance.lmRob Glance at a(n) lmRob object
tidy.survreg Tidy a(n) survreg object
tidy.glmnet Tidy a(n) glmnet object
tidy.kde Tidy a(n) kde object
glance.survexp Glance at a(n) survexp object
summary_tidiers Tidy/glance a(n) summaryDefault object
bootstrap Set up bootstrap replicates of a dplyr operation
tidy.anova Tidy a(n) anova object
tidy.Arima Tidy a(n) Arima object
tidy.binWidth Tidy a(n) binWidth object
tidy.binDesign Tidy a(n) binDesign object
glance.survfit Glance at a(n) survfit object
mcmc_tidiers Tidying methods for MCMC (Stan, JAGS, etc.) fits
glance.gam Glance at a(n) gam object
tidy.kmeans Tidy a(n) kmeans object
tidy.TukeyHSD Tidy a(n) TukeyHSD object
tidy.survdiff Tidy a(n) survdiff object
tidy.btergm Tidy a(n) btergm object
tidy.boot Tidy a(n) boot object
tidy.survexp Tidy a(n) survexp object
tidy.aareg Tidy a(n) aareg object
tidy.dist Tidy a(n) dist object
glance.poLCA Augment data with information from a(n) poLCA object
brms_tidiers Tidying methods for a brms model
tidy.confusionMatrix Tidy a(n) confusionMatrix object
tidy.cld Tidy a(n) cld object
glance.ergm Glance at a(n) ergm object
tidy.cv.glmnet Tidy a(n) cv.glmnet object
tidy.ergm Tidy a(n) ergm object
tidy.fitdistr Tidy a(n) fitdistr object
tidy.density Tidy a(n) density object
tidy.cch Tidy a(n) cch object
tidy.glht Tidy a(n) glht object
glance.muhaz Glance at a(n) muhaz object
tidy.ftable Tidy a(n) ftable object
tidy.manova Tidy a(n) manova object
tidy.coxph Tidy a(n) coxph object
tidy.coeftest Tidy a(n) coeftest object
tidy.lavaan Tidy a(n) lavaan object
tidy.map Tidy a(n) map object
tidy.roc Tidy a(n) roc object
tidy.plm Tidy a(n) plm object
tidy.poLCA Tidy a(n) poLCA object
tidy.lm Tidy a(n) lm object
glance.multinom Glance at a(n) multinom object
tidy.power.htest Tidy a(n) power.htest object
tidy.prcomp Tidy a(n) prcomp object
tidy.zoo Tidy a(n) zoo object
tidy.mjoint Tidy a(n) mjoint object
tidy.mle2 Tidy a(n) mle2 object
tidy.ridgelm Tidy a(n) ridgelm object
nlme_tidiers Tidying methods for mixed effects models
tidy.glm Tidy a(n) glm object
tidy.ivreg Tidy a(n) ivreg object
tidy_irlba Tidy a(n) irlba object masquerading as list
tidy_xyz Tidy a(n) xyz object masquerading as list
tidy.numeric Tidy atomic vectors
tidy.kappa Tidy a(n) kappa object
tidy.nlrq Tidy a(n) nlrq object
tidy.nls Tidy a(n) nls object
tidy.confint.glht Tidy a(n) confint.glht object
tidy.pyears Tidy a(n) pyears object
tidy.rcorr Tidy a(n) rcorr object
tidy.rlm Tidy a(n) rlm object
tidy.speedlm Tidy a(n) speedlm object
tidy.summary.glht Tidy a(n) summary.glht object
glance.survreg Glance at a(n) survreg object
glance_optim Tidy a(n) optim object masquerading as list
tidy.gamlss Tidy a(n) gamlss object
tidy.gam Tidy a(n) gam object
tidy.garch Tidy a(n) garch object
tidy.pairwise.htest Tidy a(n) pairwise.htest object
tidy.rq Tidy a(n) rq object
tidy.table Tidy a(n) table object
tidy.orcutt Tidy a(n) orcutt object
tidy_optim Tidy a(n) optim object masquerading as list
tidy_svd Tidy a(n) svd object masquerading as list
tidy.ts Tidy a(n) ts object
augment.betareg Augment data with information from a(n) betareg object
augment.felm Augment data with information from a(n) felm object
augment.Mclust Augment data with information from a(n) Mclust object
augment.decomposed.ts Augment data with information from a(n) decomposed.ts object
augment.coxph Augment data with information from a(n) coxph object
augment.glm Augment a(n) glm object
augment.glmRob Augment a(n) glmRob object
augment Augment data with information from a(n) statistical object
argument_glossary Allowed argument names in tidiers
augment.nls Augment data with information from a(n) nls object
augment.factanal Augment data with information from a(n) factanal object
augment.kmeans Augment data with information from a(n) kmeans object
augment.htest Augment data with information from a(n) htest object
augment.plm Augment data with information from a(n) plm object
augment.nlrq Tidy a(n) nlrq object
augment.mjoint Augment data with information from a(n) mjoint object
augment.lmRob Augment a(n) lmRob object
augment.loess Tidy a(n) loess object
No Results!

Vignettes of broom

Name
adding-tidiers.Rmd
available-methods.Rmd
bootstrapping.Rmd
broom.Rmd
broom_and_dplyr.Rmd
glossary.Rmd
kmeans.Rmd
No Results!

Last month downloads

Details

Type Package
License MIT + file LICENSE
URL http://github.com/tidyverse/broom
BugReports http://github.com/tidyverse/broom/issues
VignetteBuilder knitr
LazyData true
RoxygenNote 6.0.1.9000
NeedsCompilation no
Packaged 2018-07-16 20:37:11 UTC; alex
Repository CRAN
Date/Publication 2018-07-17 06:50:03 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/broom)](http://www.rdocumentation.org/packages/broom)