diff --git a/README.Rmd b/README.Rmd index d15915c..892d6fd 100644 --- a/README.Rmd +++ b/README.Rmd @@ -64,7 +64,7 @@ install.packages("tidyverse") install.packages("magrittr") # Or the development version from GitHub: -# install.packages("devtools") +# install.packages("pak") pak::pak("tidyverse/magrittr") ``` diff --git a/README.md b/README.md index 074b15d..03b85ac 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,11 @@ coverage](https://codecov.io/gh/tidyverse/magrittr/branch/main/graph/badge.svg)] The magrittr package offers a set of operators which make your code more readable by: -- structuring sequences of data operations left-to-right (as opposed - to from the inside and out), -- avoiding nested function calls, -- minimizing the need for local variables and function definitions, - and -- making it easy to add steps anywhere in the sequence of operations. +- structuring sequences of data operations left-to-right (as opposed to + from the inside and out), +- avoiding nested function calls, +- minimizing the need for local variables and function definitions, and +- making it easy to add steps anywhere in the sequence of operations. The operators pipe their left-hand side values forward into expressions that appear on the right-hand side, i.e. one can replace `f(x)` with @@ -57,7 +56,7 @@ install.packages("tidyverse") install.packages("magrittr") # Or the development version from GitHub: -# install.packages("devtools") +# install.packages("pak") pak::pak("tidyverse/magrittr") ``` @@ -65,9 +64,9 @@ pak::pak("tidyverse/magrittr") ### Basic piping -- `x %>% f` is equivalent to `f(x)` -- `x %>% f(y)` is equivalent to `f(x, y)` -- `x %>% f %>% g %>% h` is equivalent to `h(g(f(x)))` +- `x %>% f` is equivalent to `f(x)` +- `x %>% f(y)` is equivalent to `f(x, y)` +- `x %>% f %>% g %>% h` is equivalent to `h(g(f(x)))` Here, “equivalent” is not technically exact: evaluation is non-standard, and the left-hand side is evaluated before passed on to the right-hand @@ -76,8 +75,8 @@ implication. ### The argument placeholder -- `x %>% f(y, .)` is equivalent to `f(y, x)` -- `x %>% f(y, z = .)` is equivalent to `f(y, z = x)` +- `x %>% f(y, .)` is equivalent to `f(y, x)` +- `x %>% f(y, z = .)` is equivalent to `f(y, z = x)` ### Re-using the placeholder for attributes @@ -120,6 +119,9 @@ iris %>% subset(Sepal.Length > mean(Sepal.Length)) %$% cor(Sepal.Length, Sepal.Width) #> [1] 0.3361992 +``` + +``` r data.frame(z = rnorm(100)) %$% ts.plot(z) diff --git a/man/figures/exposition-1.png b/man/figures/exposition-1.png index 43affda..9cf0a19 100644 Binary files a/man/figures/exposition-1.png and b/man/figures/exposition-1.png differ diff --git a/src/magrittr.so b/src/magrittr.so new file mode 100755 index 0000000..b8d93ab Binary files /dev/null and b/src/magrittr.so differ diff --git a/src/pipe.o b/src/pipe.o new file mode 100644 index 0000000..5ef4004 Binary files /dev/null and b/src/pipe.o differ diff --git a/src/utils.o b/src/utils.o new file mode 100644 index 0000000..1c54863 Binary files /dev/null and b/src/utils.o differ diff --git a/tests/testthat/_snaps/pipe.md b/tests/testthat/_snaps/pipe.md index 26fe57c..f56fe08 100644 --- a/tests/testthat/_snaps/pipe.md +++ b/tests/testthat/_snaps/pipe.md @@ -2,13 +2,13 @@ Code NULL %>% f() %>% g() %>% h() - Message + Message baz bar foo Code NULL %!>% f() %!>% g() %!>% h() - Message + Message foo bar baz