B The broom() package

The broom() package provides a couple of helper functions for tidying up output from numerous R functions for running tests. This can be useful in a couple of instances, particularly for either a) accessing certain aspects of models that are not immediately accessible or b) simply for neater manipulation for multiple models.

While broom is a part of the tidyverse, it is not one of the tidyverse’s default packages. Therefore, to use the package you need to manually call it:

library(broom)

For the examples on this page, we will use datasets from the datarium package (which we have seen before), just because it provides a nice set of datasets for demonstrating how these functions work. So let’s go ahead and load that too:

library(datarium)

The main functions in broom are generic functions with what R calls several methods - i.e. ways that the function handles different types of data or objects. Every method comes with a different set of arguments that can change the output, depending on what object the function is run on. For example, if you use tidy() on an lm object, you get different optional arguments than for an aov() object, and so on. The next page gives examples using the datarium datasets.