Skip to content

Commit

Permalink
pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
dKvale committed Nov 28, 2023
1 parent 914ae49 commit f0dff17
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
8 changes: 4 additions & 4 deletions content/insert_monster_tabs_full2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@

<div class="tab-pane fade" id="groupby2" role="tabpanel" aria-labelledby="groupby-tab2">

<h3 class="blue-h3"> Average age by color </h3>
<h3 class="blue-h3"> Average age by monster color type </h3>

![](../images/monsters/groupby_summarize_pipe_monsters3){style="width: 98%; margin-top: 12px;"}
![](../images/monsters/groupby_summarize_pipe_monsters3.mpg){style="width: 95%; margin-top: 12px;"}

![](../images/monsters/groupby_summarize_single_monsters2.png){style="width: 98%; margin-top: 12px;"}

<h3 class="blue-h3" style="margin-top: 50px;"> Add a new column </h3>
<h3 class="blue-h3" style="margin-top: 50px;"> Average age and monster count by color </h3>

![](../images/monsters/groupby_summarize_pipe_multi_monsters2.png){style="width: 98%;"}
![](../images/monsters/groupby_summarize_pipe_multi_monsters2.png){style="width: 96%;"}

![](../images/monsters/groupby_summarize_multi_monsters2.png){style="width: 98%;"}
<br>
Expand Down
7 changes: 4 additions & 3 deletions content/page/Day2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ crew_df <- select(crew_df, -no_egg_allergy)
crew_df <- mutate(crew_df,
n_allergies = egg_allergy + nut_allergy)
# Now we can easily filter to crew with ANY allergies
# Filter to crew with more than zero allergies
allergy_crew_df <- filter(crew_df, n_allergies > 0)
```
Expand Down Expand Up @@ -350,8 +350,9 @@ case_when(age < 3 ~ "Baby",
TRUE ~ "Not a baby")
```

> Now we can add more life stages
<br>

> Now we can add more life stages
**Add a "Kid" option**
```{r, eval=F}
Expand All @@ -378,7 +379,7 @@ mutate(monsters,
```


## The pipe: "Take this and then..." {-}
## The pipe: *"Take this and then..."* {-}

<img src="https://raw.githubusercontent.com/rstudio/hex-stickers/master/PNG/pipe.png" style="width: 32%; margin-top: 0;">

Expand Down
15 changes: 8 additions & 7 deletions public/page/day2.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"headline": "Day 2",
"description" : "1 Data wrangling 2 Forks in the road: if_else \u002b case_when 3 Simmer it down: Summarize the data 1 Data wrangling WRANGLE that DATA Artwork by @allison_horst",
"inLanguage" : "en",
"wordCount": 1942 ,
"wordCount": 1946 ,
"datePublished" : "0001-01-01T00:00:00",
"dateModified" : "0001-01-01T00:00:00",
"image" : "https:\/\/tidy-mn.github.io\/R-camp-penguins\/images\/penguins_circle1.png",
Expand Down Expand Up @@ -674,7 +674,7 @@ <h3>Sidebar: Counting TRUE’s and FALSE’s</h3>
<span id="cb17-10"><a href="#cb17-10" tabindex="-1"></a>crew_df <span class="ot">&lt;-</span> <span class="fu">mutate</span>(crew_df, </span>
<span id="cb17-11"><a href="#cb17-11" tabindex="-1"></a> <span class="at">n_allergies =</span> egg_allergy <span class="sc">+</span> nut_allergy)</span>
<span id="cb17-12"><a href="#cb17-12" tabindex="-1"></a></span>
<span id="cb17-13"><a href="#cb17-13" tabindex="-1"></a><span class="co"># Now we can easily filter to crew with ANY allergies</span></span>
<span id="cb17-13"><a href="#cb17-13" tabindex="-1"></a><span class="co"># Filter to crew with more than zero allergies</span></span>
<span id="cb17-14"><a href="#cb17-14" tabindex="-1"></a>allergy_crew_df <span class="ot">&lt;-</span> <span class="fu">filter</span>(crew_df, n_allergies <span class="sc">&gt;</span> <span class="dv">0</span>)</span></code></pre></div>
<p><br></p>
<blockquote>
Expand Down Expand Up @@ -742,6 +742,7 @@ <h3>Back to monster babies</h3>
<p><strong>Turns into this <code>case_when()</code> statement</strong></p>
<div class="sourceCode" id="cb27"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb27-1"><a href="#cb27-1" tabindex="-1"></a><span class="fu">case_when</span>(age <span class="sc">&lt;</span> <span class="dv">3</span> <span class="sc">~</span> <span class="st">&quot;Baby&quot;</span>, </span>
<span id="cb27-2"><a href="#cb27-2" tabindex="-1"></a> <span class="cn">TRUE</span> <span class="sc">~</span> <span class="st">&quot;Not a baby&quot;</span>)</span></code></pre></div>
<p><br></p>
<blockquote>
<p>Now we can add more life stages</p>
</blockquote>
Expand All @@ -761,7 +762,7 @@ <h3>Back to monster babies</h3>
</div>
</div>
<div id="the-pipe-take-this-and-then" class="section level2 unnumbered">
<h2>The pipe: “Take this and then…”</h2>
<h2>The pipe: <em>“Take this and then…”</em></h2>
<p><img src="https://raw.githubusercontent.com/rstudio/hex-stickers/master/PNG/pipe.png" style="width: 32%; margin-top: 0;"></p>
<div id="patty-cake" class="section level3 unnumbered">
<h3>Patty cake</h3>
Expand Down Expand Up @@ -1018,14 +1019,14 @@ <h3 class="blue-h3">
</div>
<div id="groupby2" class="tab-pane fade" role="tabpanel" aria-labelledby="groupby-tab2">
<h3 class="blue-h3">
Average age by color
Average age by monster color type
</h3>
<p><img src="../images/monsters/groupby_summarize_pipe_monsters3" style="width: 98%; margin-top: 12px;" /></p>
<p><video src="../images/monsters/groupby_summarize_pipe_monsters3.mpg" style="width: 95%; margin-top: 12px;" controls=""><a href="../images/monsters/groupby_summarize_pipe_monsters3.mpg">Video</a></video></p>
<p><img src="../images/monsters/groupby_summarize_single_monsters2.png" style="width: 98%; margin-top: 12px;" /></p>
<h3 class="blue-h3" style="margin-top: 50px;">
Add a new column
Average age and monster count by color
</h3>
<p><img src="../images/monsters/groupby_summarize_pipe_multi_monsters2.png" style="width: 98%;" /></p>
<p><img src="../images/monsters/groupby_summarize_pipe_multi_monsters2.png" style="width: 96%;" /></p>
<p><img src="../images/monsters/groupby_summarize_multi_monsters2.png" style="width: 98%;" />
<br></p>
</div>
Expand Down

0 comments on commit f0dff17

Please sign in to comment.