Skip to content

Commit

Permalink
Render site
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jan 16, 2025
1 parent 3282498 commit fb194a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
8 changes: 4 additions & 4 deletions help.html
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,14 @@ <h2><strong>Why are my changes not taking effect? It’s making my results look
<p>Here we are creating a new object from an existing one:</p>
<pre class="r"><code>new_rivers &lt;- sample(rivers, 5)
new_rivers</code></pre>
<pre><code>## [1] 605 268 800 425 2315</code></pre>
<pre><code>## [1] 465 1459 380 390 360</code></pre>
<p>Using just this will only print the result and not actually change <code>new_rivers</code>:</p>
<pre class="r"><code>new_rivers + 1</code></pre>
<pre><code>## [1] 606 269 801 426 2316</code></pre>
<pre><code>## [1] 466 1460 381 391 361</code></pre>
<p>If we want to modify <code>new_rivers</code> and save that modified version, then we need to reassign <code>new_rivers</code> like so:</p>
<pre class="r"><code>new_rivers &lt;- new_rivers + 1
new_rivers</code></pre>
<pre><code>## [1] 606 269 801 426 2316</code></pre>
<pre><code>## [1] 466 1460 381 391 361</code></pre>
<p>If we forget to reassign this can cause subsequent steps to not work as expected because we will not be working with the data that has been modified.</p>
<hr />
</div>
Expand Down Expand Up @@ -403,7 +403,7 @@ <h2><strong>Error: object ‘X’ not found</strong></h2>
<p>Make sure you run something like this, with the <code>&lt;-</code> operator:</p>
<pre class="r"><code>rivers2 &lt;- new_rivers + 1
rivers2</code></pre>
<pre><code>## [1] 607 270 802 427 2317</code></pre>
<pre><code>## [1] 467 1461 382 392 362</code></pre>
<hr />
</div>
<div id="error-unexpected-in-error-unexpected-in-error-unexpected-x-in" class="section level2">
Expand Down
29 changes: 20 additions & 9 deletions modules/Functions/lab/Functions_Lab.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ <h1 class="title toc-ignore">Functions Lab</h1>
<div id="part-1" class="section level1">
<h1>Part 1</h1>
<p>Load all the libraries we will use in this lab.</p>
<pre class="r"><code>library(readr)
library(dplyr)
library(ggplot2)</code></pre>
<pre class="r"><code>library(tidyverse)</code></pre>
<div id="section" class="section level3">
<h3>1.1</h3>
<p>Create a function that takes one argument, a vector, and returns the sum of the vector and squares the result. Call it “sum_squared”. Test your function on the vector <code>c(2,7,21,30,90)</code> - you should get the answer 22500.</p>
Expand All @@ -196,6 +194,13 @@ <h3>1.4</h3>
<p>Create a new number <code>b_num</code> that is not contained with <code>nums</code>. Use your updated <code>has_n</code> function with the default value and add <code>b_num</code> as the <code>n</code> argument when calling the function. What is the outcome?</p>
</div>
</div>
<div id="practice-on-your-own" class="section level1">
<h1>Practice on Your Own!</h1>
<div id="p.1" class="section level3">
<h3>P.1</h3>
<p>Take your function from question 1.1 and have it make a print statement describing what the function is doing.</p>
</div>
</div>
<div id="part-2" class="section level1">
<h1>Part 2</h1>
<div id="section-4" class="section level3">
Expand All @@ -209,8 +214,14 @@ <h3>2.2</h3>
data %&gt;%
summarize(across(
.cols = {vector or tidyselect},
.fns = {some function},
{additional arguments}
.fns = {some function})
))</code></pre>
<p>OR</p>
<pre><code># General format
data %&gt;%
summarize(across(
.cols = {vector or tidyselect},
.fns = \(x) {some function}(x, {additional arguments})
))</code></pre>
</div>
<div id="section-6" class="section level3">
Expand All @@ -222,11 +233,11 @@ <h3>2.4</h3>
<p>Use <code>across</code> and <code>mutate</code> to convert all columns starting with the word “Total” into a binary variable: TRUE if the value is greater than 10,000,000 and FALSE if less than or equal to 10,000,000. <strong>Hint</strong>: use <code>starts_with()</code> to select the columns starting with “Total”. Use a “function on the fly” to do a logical test if the value is greater than 10,000,000.</p>
</div>
</div>
<div id="practice-on-your-own" class="section level1">
<div id="practice-on-your-own-1" class="section level1">
<h1>Practice on Your Own!</h1>
<div id="p.1" class="section level3">
<h3>P.1</h3>
<p>Take your code from question 2.4 and assign it to the variable <code>vacc_dat</code>.</p>
<div id="p.2" class="section level3">
<h3>P.2</h3>
<p>Take your code from question 2.4 and assign it to the dataset <code>vacc_dat</code>.</p>
<ul>
<li>use <code>filter()</code> to drop any rows where “United States” appears in <code>State/Territory/Federal Entity</code>. Make sure to reassign this to <code>vacc_dat</code>.</li>
<li>Create a ggplot boxplot (<code>geom_boxplot()</code>) where (1) the x-axis is <code>Total Doses Delivered</code> and (2) the y-axis is <code>Percent of fully vaccinated people with booster doses</code>.</li>
Expand Down

0 comments on commit fb194a0

Please sign in to comment.