A tidy model pipeline with twidlr and broom
@drsimonj here to show you how to go from data in a data.frame to a tidy data.frame of model output by combining twidlr and broom in a single, tidy model pipeline.
Different model functions take different types of inputs (data.frames, matrices, etc) and produce different types of output! Thus, we’re often confronted with the very untidy challenge presented in this Figure:
Thus, different models may need very different code.
However, it’s possible to create a consistent, tidy pipeline by combining the twidlr and broom packages. Let’s see how this works.
To understand the solution, think of the problem as a two-step process, depicted in this Figure:
Step 1: from data to fitted model
Step 1 must take data in a data.frame as input and return a fitted model object. twidlr exposes model functions that do just this!
Continue reading →