broom v0.5.2

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

Include our badge in your README

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