ABSTRACT

The directed acyclic graph property of a magrittr pipeline can be too restrictive for certain types of plots. After filtering data down to Houston, there is no way to recover the original data inside the pipeline. To make layering functions more modular, flexible, and expressive, the add_fun() allows the readers to pass additional arguments to a layer function. A layering function does not have to be a data-plot-pipeline itself. Its only requirement on a layering function is that the first argument is a plot object and it returns a plot object. This provides an opportunity to say, fit a model to the plot data, extract the model components the readers desire, and map those components to visuals. The “data-plot-pipeline” is desirable for a number of reasons: makes the readers' code easier to read and understand, encourages them to think of both their data and plots using a single, uniform data structure, which makes it easy to combine and reuse transformations.