From e7eab6aef3929c8c4c79ed761fff7a0898193a75 Mon Sep 17 00:00:00 2001 From: Michael Boerman Date: Thu, 5 May 2022 16:43:59 -0400 Subject: [PATCH] Suggested changed to grammar in the new pipes section (#1018) --- workflow-pipes.Rmd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/workflow-pipes.Rmd b/workflow-pipes.Rmd index 3ee85c7..15b9cb7 100644 --- a/workflow-pipes.Rmd +++ b/workflow-pipes.Rmd @@ -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.