Skip to main content

Pipelines: magrittr

  • Chapter
  • First Online:
R Data Science Quick Reference

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 34.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 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

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Thomas Mailund

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

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

Publish with us

Policies and ethics