Abstract
Data analysis consists of several steps, where your data moves through different stages of transformations and cleaning before you finally get to model construction. In practical terms, this means that your R code will consist of a series of function calls where the output of one is the input of the next. The pattern is typical, but a straightforward implementation of it has several drawbacks. The Tidyverse provides a “pipe operator” to alleviate this.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
The pipeline operator is syntactic sugar in the sense that it introduces a more readable notation for a function call. In compiled languages, syntactic sugar would be directly translated into the original form and have exactly the same runtime behavior as the sugar-free version. In R, there is no compile-time phase, so you pay a runtime cost for all syntactic sugar. The pipe operator is a complex function, so compared to explicit function calls, it is slow to use it. This is rarely an issue, though, since the expensive data processing is done inside the function and not in function calls.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2019 Thomas Mailund
About this chapter
Cite this chapter
Mailund, T. (2019). Pipelines: magrittr. In: R Data Science Quick Reference. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-4894-2_5
Download citation
DOI: https://doi.org/10.1007/978-1-4842-4894-2_5
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-4893-5
Online ISBN: 978-1-4842-4894-2
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)