broom v0.5.1

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

Include our badge in your README

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