Suggested changed to grammar in the new pipes section (#1018)

This commit is contained in:
Michael Boerman 2022-05-05 16:43:59 -04:00 committed by GitHub
parent fa0851341f
commit e7eab6aef3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -5,7 +5,7 @@ status("complete")
```
The pipe, `|>`, is a powerful tool for clearly expressing a sequence of operations that transform an object.
We briefly introduced pipes in the previous chapter but before going too much farther I wanted to give a few more details and discuss `%>%`, a predecessor to `|>`.
We briefly introduced pipes in the previous chapter, but before going too much farther, we want to give a few more details and discuss `%>%`, a predecessor to `|>`.
To add the pipe to your code, we recommend using the build-in keyboard shortcut Ctrl/Cmd + Shift + M.
You'll need to make one change to your RStudio options to use `|>` instead of `%>%` as shown in Figure \@ref(fig:pipe-options); more on `%>%` shortly.
@ -21,7 +21,7 @@ knitr::include_graphics("screenshots/rstudio-pipe-options.png")
## Why use a pipe?
Each individual dplyr verb is quite simple so solving complex problems typically requires combining multiple verbs.
Each individual dplyr verb is quite simple, so solving complex problems typically requires combining multiple verbs.
For example, the last chapter finished with a moderately complex pipe:
```{r, eval = FALSE}
@ -34,7 +34,7 @@ flights |>
)
```
Even though this pipe has four steps, it's easy to skim because the verbs come at the start of each line: we start with the flights data, then filter, then group, then summarize.
Even though this pipe has four steps, it's easy to skim because the verbs come at the start of each line: start with the flights data, then filter, then group, then summarize.
What would happen if we didn't have the pipe?
We could nest each function call inside the previous call:
@ -88,7 +88,7 @@ This allowed the base implementation to jettison infrequently used and less impo
## `|>` vs `%>%`
While `|>` and `%>%` behave identically for simple cases there are a few important differences.
While `|>` and `%>%` behave identically for simple cases, there are a few important differences.
These are most likely to affect you if you're a long-term user of `%>%` who has taken advantage of some of the more advanced features.
But they're still good to know about even if you've never used `%>%` because you're likely to encounter some of them when reading wild-caught code.