Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct installation instructions to reflect update to use pak #274

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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")
```

Expand Down
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -57,17 +56,17 @@ install.packages("tidyverse")
install.packages("magrittr")

# Or the development version from GitHub:
# install.packages("devtools")
# install.packages("pak")
pak::pak("tidyverse/magrittr")
```

## Usage

### 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
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down
Binary file modified man/figures/exposition-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/magrittr.so
Binary file not shown.
Binary file added src/pipe.o
Binary file not shown.
Binary file added src/utils.o
Binary file not shown.
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/pipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

Code
NULL %>% f() %>% g() %>% h()
Message <simpleMessage>
Message
baz
bar
foo
Code
NULL %!>% f() %!>% g() %!>% h()
Message <simpleMessage>
Message
foo
bar
baz
Expand Down
Loading