broom v0.7.0

0

Monthly downloads

0th

Percentile

Convert Statistical 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 R build
status Codecov test
coverage

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 availability.

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 
# modeling set, which includes broom:
install.packages("tidymodels")

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

# to get the development version from GitHub:
install.packages("devtools")
devtools::install_github("tidymodels/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(Volume ~ Girth + Height, trees)
tidy(fit)
#> # A tibble: 3 x 5
#>   term        estimate std.error statistic  p.value
#>   <chr>          <dbl>     <dbl>     <dbl>    <dbl>
#> 1 (Intercept)  -58.0       8.64      -6.71 2.75e- 7
#> 2 Girth          4.71      0.264     17.8  8.22e-17
#> 3 Height         0.339     0.130      2.61 1.45e- 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 12
#>   r.squared adj.r.squared sigma statistic  p.value    df logLik   AIC   BIC
#>       <dbl>         <dbl> <dbl>     <dbl>    <dbl> <dbl>  <dbl> <dbl> <dbl>
#> 1     0.948         0.944  3.88      255. 1.07e-18     2  -84.5  177.  183.
#> # … with 3 more variables: deviance <dbl>, df.residual <int>, nobs <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 = trees)
#> # A tibble: 31 x 9
#>    Girth Height Volume .fitted .resid .std.resid   .hat .sigma   .cooksd
#>    <dbl>  <dbl>  <dbl>   <dbl>  <dbl>      <dbl>  <dbl>  <dbl>     <dbl>
#>  1   8.3     70   10.3    4.84 -5.46      1.50   0.116    3.79 0.0978   
#>  2   8.6     65   10.3    4.55 -5.75      1.60   0.147    3.77 0.148    
#>  3   8.8     63   10.2    4.82 -5.38      1.53   0.177    3.78 0.167    
#>  4  10.5     72   16.4   15.9  -0.526     0.140  0.0592   3.95 0.000409 
#>  5  10.7     81   18.8   19.9   1.07     -0.294  0.121    3.95 0.00394  
#>  6  10.8     83   19.7   21.0   1.32     -0.370  0.156    3.94 0.00840  
#>  7  11       66   15.6   16.2   0.593    -0.162  0.115    3.95 0.00114  
#>  8  11       75   18.2   19.2   1.05     -0.277  0.0515   3.95 0.00138  
#>  9  11.1     80   22.6   21.4  -1.19      0.321  0.0920   3.95 0.00348  
#> 10  11.2     75   19.9   20.2   0.288    -0.0759 0.0480   3.95 0.0000968
#> # … with 21 more rows

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 tidier methods for new model objects, please read this article on the tidymodels website.

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

Functions in broom

Name Description
augment.drc Augment data with information from a(n) drc object
augment.nls Augment data with information from a(n) nls object
augment.nlrq Tidy a(n) nlrq object
augment.rqs Augment data with information from a(n) rqs object
augment.fixest Augment data with information from a(n) fixest object
augment.felm Augment data with information from a(n) felm object
augment.lmRob Augment data with information from a(n) lmRob object
augment.sarlm Augment data with information from a(n) spatialreg object
augment.loess Tidy a(n) loess object
augment_columns add fitted values, residuals, and other common outputs to an augment call
glance.Arima Glance at a(n) Arima object
augment.Mclust Augment data with information from a(n) Mclust object
augment.glm Augment data with information from a(n) glm object
augment.glmRob Augment data with information from a(n) glmRob object
augment.betamfx Augment data with information from a(n) betamfx object
augment.factanal Augment data with information from a(n) factanal object
augment.pam Augment data with information from a(n) pam object
augment.rma Augment data with information from a(n) rma object
augment.glmrob Augment data with information from a(n) glmrob object
glance.gam Glance at a(n) gam object
glance.clm Glance at a(n) clm object
glance.garch Tidy a(n) garch object
glance.clmm Glance at a(n) clmm object
glance.geeglm Glance at a(n) geeglm object
bootstrap Set up bootstrap replicates of a dplyr operation
augment.speedlm Augment data with information from a(n) speedlm object
augment.smooth.spline Tidy a(n) smooth.spline object
glance.aov Glance at a(n) lm object
data.frame_tidiers Tidiers for data.frame objects
glance.betamfx Glance at a(n) betamfx object
glance.mfx Glance at a(n) mfx object
augment.plm Augment data with information from a(n) plm object
durbinWatsonTest_tidiers Tidy/glance a(n) durbinWatsonTest object
glance.binDesign Glance at a(n) binDesign object
glance.glm Glance at a(n) glm object
glance.glmRob Glance at a(n) glmRob object
glance.cch Glance at a(n) cch object
augment.survreg Augment data with information from a(n) survreg object
augment.stl Augment data with information from a(n) stl object
glance.aareg Glance at a(n) aareg object
glance.Mclust Glance at a(n) Mclust object
glance.coxph Glance at a(n) coxph object
glance.ivreg Glance at a(n) ivreg object
glance.kmeans Glance at a(n) kmeans object
glance.nlrq Glance at a(n) nlrq object
glance.nls Glance at a(n) nls object
glance.rlm Glance at a(n) rlm object
glance.ridgelm Glance at a(n) ridgelm object
glance.cv.glmnet Glance at a(n) cv.glmnet object
glance.mjoint Glance at a(n) mjoint object
glance.orcutt Glance at a(n) orcutt object
null_tidiers Tidiers for NULL inputs
glance.pam Glance at a(n) pam object
glance.fitdistr Glance at a(n) fitdistr object
glance.fixest Glance at a(n) fixest object
glance.glmnet Glance at a(n) glmnet object
glance.drc Glance at a(n) drc object
glance.ergm Glance at a(n) ergm object
reexports Objects exported from other packages
augment.coxph Augment data with information from a(n) coxph object
tidy.TukeyHSD Tidy a(n) TukeyHSD object
tidy.Mclust Tidy a(n) Mclust object
glance.speedlm Glance at a(n) speedlm object
augment.decomposed.ts Augment data with information from a(n) decomposed.ts object
glance.survdiff Glance at a(n) survdiff object
augment.betareg Augment data with information from a(n) betareg object
glance.gmm Glance at a(n) gmm object
tidy.boot Tidy a(n) boot object
glance.muhaz Glance at a(n) muhaz object
glance.lmRob Glance at a(n) lmRob object
glance.lmodel2 Glance at a(n) lmodel2 object
glance.multinom Glance at a(n) multinom object
glance.lmrob Glance at a(n) lmrob object
tidy.fixest Tidy a(n) fixest object
tidy.ftable (Deprecated) Tidy ftable objects
glance.rma Glance at a(n) rma object
tidy.btergm Tidy a(n) btergm object
augment.clm Augment data with information from a(n) clm object
augment.mfx Augment data with information from a(n) mfx object
augment.lm Augment data with information from a(n) lm object
augment.rlm Augment data with information from a(n) rlm object
augment.prcomp Augment data with information from a(n) prcomp object
augment.rq Augment data with information from a(n) rq object
confint_tidy (Deprecated) Calculate confidence interval as a tidy data frame
augment.kmeans Augment data with information from a(n) kmeans object
augment.lmrob Augment data with information from a(n) lmrob object
augment.mjoint Augment data with information from a(n) mjoint object
broom Convert Statistical Objects into Tidy Tibbles
glance.polr Glance at a(n) polr object
glance.pyears Glance at a(n) pyears object
glance.rq Glance at a(n) rq object
glance.sarlm Glance at a(n) spatialreg object
glance.svyolr Glance at a(n) svyolr object
augment.poLCA Augment data with information from a(n) poLCA object
finish_glance (Deprecated) Add logLik, AIC, BIC, and other common measurements to a glance of a prediction
augment.polr Augment data with information from a(n) polr object
glance_optim Tidy a(n) optim object masquerading as list
fix_data_frame Ensure an object is a data frame, with rownames moved into a column
glance.survexp Glance at a(n) survexp object
summary_tidiers (Deprecated) Tidy summaryDefault objects
list_tidiers Tidying methods for lists / returned values that are not S3 objects
tidy.rma Tidy a(n) rma object
tidy.density (Deprecated) Tidy density objects
tidy.ergm Tidy a(n) ergm object
tidy.cv.glmnet Tidy a(n) cv.glmnet object
tidy.glm Tidy a(n) glm object
sp_tidiers Tidy a(n) SpatialPolygonsDataFrame object
sparse_tidiers Tidy a sparseMatrix object from the Matrix package
tidy.anova Tidy a(n) anova object
glance.survfit Glance at a(n) survfit object
tidy.Arima Tidy a(n) Arima object
tidy.factanal Tidy a(n) factanal object
glance.betareg Glance at a(n) betareg object
tidy.aov Tidy a(n) aov object
tidy.aovlist Tidy a(n) aovlist object
tidy.coeftest Tidy a(n) coeftest object
tidy.clm Tidy a(n) clm object
tidy.clmm Tidy a(n) clmm object
tidy.dist (Deprecated) Tidy dist objects
tidy.betamfx Tidy a(n) betamfx object
tidy.confint.glht Tidy a(n) confint.glht object
tidy.drc Tidy a(n) drc object
tidy.geeglm Tidy a(n) geeglm object
tidy.htest Tidy/glance a(n) htest object
tidy.glmRob Tidy a(n) glmRob object
tidy.glht Tidy a(n) glht object
tidy.biglm Tidy a(n) biglm object
tidy.Kendall Tidy a(n) Kendall object
tidy.confusionMatrix Tidy a(n) confusionMatrix object
tidy.betareg Tidy a(n) betareg object
tidy.gam Tidy a(n) gam object
tidy.coxph Tidy a(n) coxph object
tidy.kappa Tidy a(n) kappa object
tidy.mle2 Tidy a(n) mle2 object
tidy.kde Tidy a(n) kde object
tidy.kmeans Tidy a(n) kmeans object
tidy.emmGrid Tidy a(n) emmGrid object
glance.biglm Glance at a(n) biglm object
tidy.epi.2by2 Tidy a(n) epi.2by2 object
tidy.lsmobj Tidy a(n) lsmobj object
tidy.mlm Tidy a(n) mlm object
tidy.ivreg Tidy a(n) ivreg object
tidy.pyears Tidy a(n) pyears object
glance.felm Glance at a(n) felm object
glance.factanal Glance at a(n) factanal object
glance.lm Glance at a(n) lm object
glance.lavaan Glance at a(n) lavaan object
tidy.lavaan Tidy a(n) lavaan object
tidy.glmrob Tidy a(n) glmrob object
glance.plm Glance at a(n) plm object
tidy.rcorr Tidy a(n) rcorr object
tidy.mediate Tidy a(n) mediate object
tidy.plm Tidy a(n) plm object
tidy.sarlm Tidying methods for spatially autoregressive models
tidy.lm.beta Tidy a(n) lm.beta object
tidy.rqs Tidy a(n) rqs object
tidy.lm Tidy a(n) lm object
tidy.pam Tidy a(n) pam object
tidy.map Tidy a(n) map object
glance.poLCA Glance at a(n) poLCA object
glance.smooth.spline Tidy a(n) smooth.spine object
tidy.roc Tidy a(n) roc object
glance.speedglm Glance at a(n) speedglm object
tidy.table Tidy a(n) table object
tidy.speedlm Tidy a(n) speedlm object
tidy.lmrob Tidy a(n) lmrob object
tidy.summary.glht Tidy a(n) summary.glht object
tidy.ts Tidy a(n) ts object
tidy.rq Tidy a(n) rq object
tidy.nlrq Tidy a(n) nlrq object
tidy.manova Tidy a(n) manova object
tidy.nls Tidy a(n) nls object
tidy.summary_emm Tidy a(n) summary_emm object
glance.survreg Glance at a(n) survreg object
tidy.survdiff Tidy a(n) survdiff object
tidy.glmnet Tidy a(n) glmnet object
tidy.gmm Tidy a(n) gmm object
tidy.power.htest Tidy a(n) power.htest object
tidy.mfx Tidy a(n) mfx object
tidy.survexp Tidy a(n) survexp object
tidy.mjoint Tidy a(n) mjoint object
tidy.survfit Tidy a(n) survfit object
tidy.systemfit Tidy a(n) systemfit object
tidy.svyolr Tidy a(n) svyolr object
tidy.poLCA Tidy a(n) poLCA object
tidy.polr Tidy a(n) polr object
glance.svyglm Glance at a(n) svyglm object
tidy.svyglm Tidy a(n) svyglm object
tidy.survreg Tidy a(n) survreg object
tidy_optim Tidy a(n) optim object masquerading as list
tidy_svd Tidy a(n) svd object masquerading as list
tidy.aareg Tidy a(n) aareg object
tidy.acf Tidy a(n) acf object
tidy.binDesign Tidy a(n) binDesign object
tidy.binWidth Tidy a(n) binWidth object
tidy.rlm Tidy a(n) rlm object
tidy.prcomp Tidy a(n) prcomp object
tidy.ridgelm Tidy a(n) ridgelm object
tidy.cch Tidy a(n) cch object
tidy.cld Tidy a(n) cld object
tidy_xyz Tidy a(n) xyz object masquerading as list
tidy.numeric Tidy atomic vectors
tidy.fitdistr Tidy a(n) fitdistr object
tidy.felm Tidy a(n) felm object
tidy.gamlss Tidy a(n) gamlss object
tidy.garch Tidy a(n) garch object
tidy.lmRob Tidy a(n) lmRob object
tidy.lmodel2 Tidy a(n) lmodel2 object
tidy.muhaz Tidy a(n) muhaz object
tidy.orcutt Tidy a(n) orcutt object
tidy.ref.grid Tidy a(n) ref.grid object
tidy.multinom Tidying methods for multinomial logistic regression models
tidy.pairwise.htest Tidy a(n) pairwise.htest object
tidy.regsubsets Tidy a(n) regsubsets object
tidy.speedglm Tidy a(n) speedglm object
tidy.spec Tidy a(n) spec object
tidy.zoo Tidy a(n) zoo object
tidy_irlba Tidy a(n) irlba object masquerading as list
augment.htest Augment data with information from a(n) htest object
augment.ivreg Augment data with information from a(n) ivreg object
No Results!

Vignettes of broom

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

Last month downloads

Details

Type Package
License MIT + file LICENSE
URL https://broom.tidymodels.org/, http://github.com/tidymodels/broom
BugReports http://github.com/tidymodels/broom/issues
VignetteBuilder knitr
Encoding UTF-8
LazyData true
RoxygenNote 7.1.0.9000
Language en-US
Collate 'aaa-documentation-helper.R' 'null-and-default-tidiers.R' 'aer-tidiers.R' 'auc-tidiers.R' 'base-tidiers.R' 'bbmle-tidiers.R' 'betareg-tidiers.R' 'biglm-tidiers.R' 'bingroup-tidiers.R' 'boot-tidiers.R' 'broom-package.R' 'broom.R' 'btergm-tidiers.R' 'car-tidiers.R' 'caret-tidiers.R' 'data-frame-tidiers.R' 'deprecated-0-7-0.R' 'drc-tidiers.R' 'emmeans-tidiers.R' 'epiR-tidiers.R' 'ergm-tidiers.R' 'fixest-tidiers.R' 'gam-tidiers.R' 'gamlss-tidiers.R' 'gee.R' 'geepack-tidiers.R' 'glmnet-cv-glmnet-tidiers.R' 'glmnet-glmnet-tidiers.R' 'gmm-tidiers.R' 'hmisc-tidiers.R' 'joinerml-tidiers.R' 'kendall-tidiers.R' 'ks-tidiers.R' 'lavaan-tidiers.R' 'leaps.R' 'lfe-tidiers.R' 'list-irlba.R' 'list-optim-tidiers.R' 'list-svd-tidiers.R' 'list-tidiers.R' 'list-xyz-tidiers.R' 'lm-beta-tidiers.R' 'lmodel2-tidiers.R' 'lmtest-tidiers.R' 'maps-tidiers.R' 'mass-fitdistr-tidiers.R' 'mass-polr-tidiers.R' 'mass-ridgelm-tidiers.R' 'stats-lm-tidiers.R' 'mass-rlm-tidiers.R' 'matrix-tidiers.R' 'mclogit.R' 'mclust-tidiers.R' 'mediate-tidiers.R' 'mfx-tidiers.R' 'mgcv-tidiers.R' 'muhaz-tidiers.R' 'multcomp-tidiers.R' 'nnet-tidiers.R' 'nobs.R' 'orcutt-tidiers.R' 'ordinal-clm-tidiers.R' 'ordinal-clmm-tidiers.R' 'pam-tidiers.R' 'plm-tidiers.R' 'polca-tidiers.R' 'psych-tidiers.R' 'stats-nls-tidiers.R' 'quantreg-nlrq-tidiers.R' 'quantreg-rq-tidiers.R' 'quantreg-rqs-tidiers.R' 'rma-tidiers.R' 'robust-glmrob-tidiers.R' 'robust-lmrob-tidiers.R' 'robustbase-glmrob-tidiers.R' 'robustbase-lmrob-tidiers.R' 'scam-tidiers.R' 'sp-tidiers.R' 'spdep-tidiers.R' 'speedglm-speedglm-tidiers.R' 'speedglm-speedlm-tidiers.R' 'stats-anova-tidiers.R' 'stats-arima-tidiers.R' 'stats-decompose-tidiers.R' 'stats-factanal-tidiers.R' 'stats-glm-tidiers.R' 'stats-htest-tidiers.R' 'stats-kmeans-tidiers.R' 'stats-loess-tidiers.R' 'stats-mlm-tidiers.R' 'stats-prcomp-tidiers.R' 'stats-smooth.spline-tidiers.R' 'stats-time-series-tidiers.R' 'survey-tidiers.R' 'survival-aareg-tidiers.R' 'survival-cch-tidiers.R' 'survival-coxph-tidiers.R' 'survival-pyears-tidiers.R' 'survival-survdiff-tidiers.R' 'survival-survexp-tidiers.R' 'survival-survfit-tidiers.R' 'survival-survreg-tidiers.R' 'systemfit-tidiers.R' 'tseries-tidiers.R' 'utilities.R' 'zoo-tidiers.R' 'zzz.R'
NeedsCompilation no
Packaged 2020-06-25 19:51:26 UTC; simonpcouch
Repository CRAN
Date/Publication 2020-07-09 12:30:09 UTC
suggests AER , akima , AUC , bbmle , betareg , biglm , binGroup , boot , btergm , car , caret , cluster , coda , covr , drc , e1071 , emmeans , epiR , ergm , fixest (>= 0.3.1) , gam (>= 1.15) , gamlss , gamlss.data , gamlss.dist , gee , geepack , ggplot2 , glmnet , glmnetUtils , gmm , Hmisc , irlba , joineRML , Kendall , knitr , ks , Lahman , lavaan , leaps , lfe , lm.beta , lme4 , lmodel2 , lmtest , lsmeans , maps , maptools , MASS , Matrix , mclogit , mclust , mediation , metafor , mfx , mgcv , modeldata , modeltests , muhaz , multcomp , network , nnet , orcutt (>= 2.2) , ordinal , plm , poLCA , psych , quantreg , rgeos , rmarkdown , robust , robustbase , rsample , sandwich , sp , spatialreg , spdep , speedglm , spelling , statnet.common , survey , survival , systemfit , testthat (>= 2.1.0) , tseries , zoo
imports backports , dplyr , ellipsis , generics (>= 0.0.2) , glue , methods , purrr , rlang , stringr , tibble (>= 3.0.0) , tidyr
depends R (>= 3.1)
Contributors Roger Bivand, Matthieu Stigler, Benjamin Nutter, PaulChristian Buerkner, Luciano Selzer, David Robinson, Frederik Aust, Eduard Szcs, Greg Macfarlane, Matthieu Gomez, Francois Briatte, Sergio Oller Moreno, Matthew Lincoln, Michal Bojanowski, Hao Zhu, Simon Jackson, Vilmantas Gegzna, Boris Demeshev, Jonah Gabry, Lukasz Komsta, Joseph Larmarange, Hadley Wickham, Henrik Bengtsson, Jeffrey B. Arnold, Dieter Menne, Steven E. Pav, Sven Templer, David Hugh-Jones, Vincent Arel-Bundock, Ben Bolker, Gavin Simpson, Jim Hester, Luke Johnston, Jens Preussner, Jay Hesselberth, Bill Denney, Matthew Kay, Hong Ooi, Jennifer Bryan, Jasper Cooper, Max Kuhn, Brian A. Fannin, Jorge Cimentada, Derek Chiu, Bernie Gray, Jason Cory Brunson, Alessandro Gasparini, Aaron Jacobs, Luke Sonnet, Indrajeet Patil, Malcolm Barrett, Simon P. Couch, Patrick Kennedy, Frederick Novometsky, Wilson Freitas, Michelle Evans, Ben Whalley, Michael Kuehn, Erle Holgersen, Karl Dunkle Werner, Lily Medina, Erwan Le Pennec, Nic Crane, Kevin Zarca, Tyler Littlefield, Nick Williams, Andreas Bender, Bruna Wundervald, James Martherus, Grant McDermott, Shiro Kuriwaki, Andrew Bates, Karissa Whiting, Yves Rosseel, Ethan Christensen, Paul PJ, Ben Schneider, Jason Muhlenkamp, Matt Lehman, Hideaki Hayashi, Luis Tobalina, Annie Wang, Wei Yang Tham, Clara Wang, Abby Smith, E Auden Krauska, Alex Wang, Charles Gray, Jared Wilber, Angus Moore, Marius Barth, Joyce Cahoon, Lukas Wallrich, Chuliang Xiao, Hakon Malmedal, Clara Wang, Mara Averick, Johan Junkka, Benjamin Soltoff, Zoe Wilkinson Saldana, Shabbh E. Banks, Serina Robinson, Riinu Ots, Nina Jakobsen, Michael Weylandt, Lisa Lendway, Karl Hailperin, Josue Rodriguez, Chris Jarvis, Brian Mannakee, Drew Tyre, Shreyas Singh, Laurens Geffert

Include our badge in your README

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