2121 A pipe expression passes , or pipes , the result of the left - hand side
2222 expression \code {lhs } to the right - hand side expression \code {rhs }.
2323
24- %If the \code {rhs } expression is a call , then the
2524 The \code {lhs } is
2625 inserted as the first argument in the call. So \code {x | > f(y )} is
2726 interpreted as \code {f(x , y )}.
2827
2928 To avoid ambiguities , functions in \code {rhs } calls may not be
3029 syntactically special , such as \code {+ } or \code {if }.
3130
31+ It is also possible to use a named argument with the placeholder
32+ \code {_} in the \code {rhs } call to specify where the \code {lhs } is to
33+ be inserted. The placeholder can only appear once on the \code {rhs }.
34+
3235 Pipe notation allows a nested sequence of calls to be written in a way
3336 that may make the sequence of processing steps easier to follow.
3437
@@ -54,10 +57,13 @@ mtcars |> head() # same as head(mtcars)
5457mtcars | > head(2 ) # same as head(mtcars, 2)
5558mtcars | > subset(cyl == 4 ) | > nrow() # same as nrow(subset(mtcars, cyl == 4))
5659
57- # passing the lhs into an argument other than the first, either:
60+ # to pass the lhs into an argument other than the first, either
61+ # use the _ placeholder with a named argument:
62+ mtcars | > subset(cyl == 4 ) | > lm(mpg ~ disp , data = _)
63+ # or use an anonymous function:
5864mtcars | > subset(cyl == 4 ) | > (function (d ) lm(mpg ~ disp , data = d ))()
5965mtcars | > subset(cyl == 4 ) | > (\(d ) lm(mpg ~ disp , data = d ))()
60- # or explicitly naming the argument(s) before the "one":
66+ # or explicitly name the argument(s) before the "one":
6167mtcars | > subset(cyl == 4 ) | > lm(formula = mpg ~ disp )
6268
6369# the pipe operator is implemented as a syntax transformation:
0 commit comments