Skip to content

Commit

Permalink
Merge pull request #155 from grifbai/patch-1
Browse files Browse the repository at this point in the history
Update 05_using_pipes.Rmd
  • Loading branch information
mbcann01 authored May 23, 2024
2 parents 625e562 + a41e1d7 commit 64160c1
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ We can also use a pipe to pass the `height_and_weight` data frame to the `filter
height_and_weight |> filter(sex == "Female")
```

As you can see, we get the exact same result. So, the R interpreter took the thing on the left side of the pipe operator, stuck it into the first argument of the function on the right side of the pipe operator, and then executed the function. In this case, the `filter()` function needs a value supplied to two arguments in order work. So, we wrote `sex == "Female"` inside of the `filter()` function's parentheses. When we see `height_and_weight |> filter(sex == "Female")`, R sees `filter(height_and_weight, sex == "Female")`.
As you can see, we get the exact same result. So, the R interpreter took the thing on the left side of the pipe operator, stuck it into the first argument of the function on the right side of the pipe operator, and then executed the function. In this case, the `filter()` function needs a value supplied to two arguments in order to work. So, we wrote `sex == "Female"` inside of the `filter()` function's parentheses. When we see `height_and_weight |> filter(sex == "Female")`, R sees `filter(height_and_weight, sex == "Female")`.

<p class="note"> 🗒**Side Note:** This pattern -- a data frame piped into a function, which is usually then piped into one or more additional functions is something that you will see over and over in this book.</p>

Expand Down

0 comments on commit 64160c1

Please sign in to comment.