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 Jun 12, 2024
1 parent 634781d commit a430122
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
8 changes: 4 additions & 4 deletions help.html
Original file line number Diff line number Diff line change
Expand Up @@ -405,16 +405,16 @@ <h2><strong>Why are my changes not taking effect? It’s making my results
<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] 900 407 538 870 505</code></pre>
<pre><code>## [1] 310 625 1885 800 524</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] 901 408 539 871 506</code></pre>
<pre><code>## [1] 311 626 1886 801 525</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] 901 408 539 871 506</code></pre>
<pre><code>## [1] 311 626 1886 801 525</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>
Expand Down Expand Up @@ -484,7 +484,7 @@ <h2><strong>Error: object ‘X’ not found</strong></h2>
operator:</p>
<pre class="r"><code>rivers2 &lt;- new_rivers + 1
rivers2</code></pre>
<pre><code>## [1] 902 409 540 872 507</code></pre>
<pre><code>## [1] 312 627 1887 802 526</code></pre>
<hr />
</div>
<div id="error-unexpected-in-error-unexpected-in-error-unexpected-x-in"
Expand Down
25 changes: 18 additions & 7 deletions modules/Subsetting_Data_in_R/Subsetting_Data_in_R.html
Original file line number Diff line number Diff line change
Expand Up @@ -3321,6 +3321,16 @@ <h1 data-config-title><!-- populated from slide_config.json --></h1>

<pre class = 'prettyprint lang-r'>library(tidyverse) # loads dplyr and other packages!</pre>

<pre >── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ forcats 1.0.0 ✔ readr 2.1.5
✔ ggplot2 3.5.0 ✔ stringr 1.5.1
✔ lubridate 1.9.3 ✔ tibble 3.2.1
✔ purrr 1.0.2 ✔ tidyr 1.3.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (&lt;http://conflicted.r-lib.org/&gt;) to force all conflicts to become errors</pre>

</article></slide><slide class=""><hgroup><h2>Getting data to work with</h2></hgroup><article id="getting-data-to-work-with">

<p>We will use a dataset from a project we worked on called Open Case Studies.</p>
Expand All @@ -3339,7 +3349,8 @@ <h1 data-config-title><!-- populated from slide_config.json --></h1>

<p>We will work with data called <code>annualDosage</code> (number of shipments (count) of either oxycodone or hydrocodone pills (DOSAGE_UNIT)).</p>

<pre class = 'prettyprint lang-r'>annualDosage &lt;- read_csv(&quot;https://jhudatascience.org/intro_to_r/data/annualDosage.csv&quot;)</pre>
<pre class = 'prettyprint lang-r'>annualDosage &lt;-
read_csv(&quot;https://jhudatascience.org/intro_to_r/data/annualDosage.csv&quot;)</pre>

<pre >Rows: 27758 Columns: 6
── Column specification ────────────────────────────────────────────────────────
Expand Down Expand Up @@ -3388,18 +3399,18 @@ <h1 data-config-title><!-- populated from slide_config.json --></h1>
<pre class = 'prettyprint lang-r'>slice_sample(annualDosage, n = 2)</pre>

<pre ># A tibble: 2 × 6
BUYER_COUNTY BUYER_STATE year count DOSAGE_UNIT countyfips
&lt;chr&gt; &lt;chr&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;chr&gt;
1 COCKE TN 2006 5340 2798590 47029
2 DODGE GA 2011 3861 1346460 13091 </pre>
BUYER_COUNTY BUYER_STATE year count DOSAGE_UNIT countyfips
&lt;chr&gt; &lt;chr&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;chr&gt;
1 SANTA BARBARA CA 2008 27089 13434615 06083
2 SPALDING GA 2013 9441 3420300 13255 </pre>

<pre class = 'prettyprint lang-r'>slice_sample(annualDosage, n = 2)</pre>

<pre ># A tibble: 2 × 6
BUYER_COUNTY BUYER_STATE year count DOSAGE_UNIT countyfips
&lt;chr&gt; &lt;chr&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;chr&gt;
1 CRAWFORD GA 2009 313 110780 13079
2 HENRY VA 2010 4440 2541640 51089 </pre>
1 MURRAY OK 2013 2466 1140330 40099
2 BRISTOL RI 2006 2533 918200 44001 </pre>

</article></slide><slide class="segue dark nobackground level1"><hgroup class = 'auto-fadein'><h2>Data frames and tibbles</h2></hgroup><article id="data-frames-and-tibbles">

Expand Down

0 comments on commit a430122

Please sign in to comment.