@@ -17,12 +17,11 @@ coverage](https://codecov.io/gh/tidyverse/magrittr/branch/main/graph/badge.svg)]
17
17
The magrittr package offers a set of operators which make your code more
18
18
readable by:
19
19
20
- - structuring sequences of data operations left-to-right (as opposed
21
- to from the inside and out),
22
- - avoiding nested function calls,
23
- - minimizing the need for local variables and function definitions,
24
- and
25
- - making it easy to add steps anywhere in the sequence of operations.
20
+ - structuring sequences of data operations left-to-right (as opposed to
21
+ from the inside and out),
22
+ - avoiding nested function calls,
23
+ - minimizing the need for local variables and function definitions, and
24
+ - making it easy to add steps anywhere in the sequence of operations.
26
25
27
26
The operators pipe their left-hand side values forward into expressions
28
27
that appear on the right-hand side, i.e. one can replace ` f(x) ` with
@@ -57,17 +56,17 @@ install.packages("tidyverse")
57
56
install.packages(" magrittr" )
58
57
59
58
# Or the development version from GitHub:
60
- # install.packages("devtools ")
59
+ # install.packages("pak ")
61
60
pak :: pak(" tidyverse/magrittr" )
62
61
```
63
62
64
63
## Usage
65
64
66
65
### Basic piping
67
66
68
- - ` x %>% f ` is equivalent to ` f(x) `
69
- - ` x %>% f(y) ` is equivalent to ` f(x, y) `
70
- - ` x %>% f %>% g %>% h ` is equivalent to ` h(g(f(x))) `
67
+ - ` x %>% f ` is equivalent to ` f(x) `
68
+ - ` x %>% f(y) ` is equivalent to ` f(x, y) `
69
+ - ` x %>% f %>% g %>% h ` is equivalent to ` h(g(f(x))) `
71
70
72
71
Here, “equivalent” is not technically exact: evaluation is non-standard,
73
72
and the left-hand side is evaluated before passed on to the right-hand
@@ -76,8 +75,8 @@ implication.
76
75
77
76
### The argument placeholder
78
77
79
- - ` x %>% f(y, .) ` is equivalent to ` f(y, x) `
80
- - ` x %>% f(y, z = .) ` is equivalent to ` f(y, z = x) `
78
+ - ` x %>% f(y, .) ` is equivalent to ` f(y, x) `
79
+ - ` x %>% f(y, z = .) ` is equivalent to ` f(y, z = x) `
81
80
82
81
### Re-using the placeholder for attributes
83
82
@@ -120,6 +119,9 @@ iris %>%
120
119
subset(Sepal.Length > mean(Sepal.Length )) %$ %
121
120
cor(Sepal.Length , Sepal.Width )
122
121
# > [1] 0.3361992
122
+ ```
123
+
124
+ ``` r
123
125
124
126
data.frame (z = rnorm(100 )) %$ %
125
127
ts.plot(z )
0 commit comments