magrittr
Magrittr is an R package that provides a set of pipe operators designed to simplify the construction of expressive, readable data pipelines. By enabling left-to-right chaining of operations, it minimizes nested function calls and clarifies the flow of data through a sequence of transformations. The most widely used operator is the forward pipe, %>%, which passes the left-hand side as the first argument to the function on its right. Additional operators include %<>% (compound assignment pipe), which reassigns the result to the left-hand side; %T>% (tee pipe), which performs a side effect while passing through the original value; and %$% (exposition pipe), which evaluates the right-hand side with the left-hand side’s names available as variables.
A central feature is the placeholder . that can be used within the right-hand expression to indicate
Typical usage examples: library(magrittr); mtcars %>% head(5) %>% lm(mpg ~ wt, data = .); or mtcars %>% filter(hp > 100) %>% summarize(avg_hp = mean(hp)).
Magrittr has had a major influence on R programming and is widely used in the tidyverse. Its