Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/jhudsl/intro_to_r into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jhudsl-robot committed Jun 23, 2023
2 parents bd09aa5 + 3d2f473 commit 20302b0
Show file tree
Hide file tree
Showing 28 changed files with 79 additions and 79 deletions.
Binary file modified modules/Basic_R/Basic_R.pdf
Binary file not shown.
20 changes: 10 additions & 10 deletions modules/Basic_R/lab/Basic_R_Lab_Key.html
Original file line number Diff line number Diff line change
Expand Up @@ -308,16 +308,16 @@ <h1>Part 3</h1>
replace = TRUE
)
my_responses</code></pre>
<pre><code>## [1] &quot;Strongly Disagree&quot; &quot;Neutral&quot; &quot;Neutral&quot;
## [4] &quot;Neutral&quot; &quot;Strongly Agree&quot; &quot;Strongly Disagree&quot;
## [7] &quot;Neutral&quot; &quot;Neutral&quot; &quot;Strongly Disagree&quot;
## [10] &quot;Neutral&quot; &quot;Disagree&quot; &quot;Strongly Agree&quot;
## [13] &quot;Neutral&quot; &quot;Agree&quot; &quot;Strongly Agree&quot;
## [16] &quot;Agree&quot; &quot;Agree&quot; &quot;Neutral&quot;
## [19] &quot;Disagree&quot; &quot;Strongly Disagree&quot; &quot;Agree&quot;
## [22] &quot;Disagree&quot; &quot;Strongly Disagree&quot; &quot;Strongly Disagree&quot;
## [25] &quot;Strongly Disagree&quot; &quot;Strongly Disagree&quot; &quot;Agree&quot;
## [28] &quot;Disagree&quot; &quot;Disagree&quot; &quot;Strongly Disagree&quot;</code></pre>
<pre><code>## [1] &quot;Agree&quot; &quot;Strongly Agree&quot; &quot;Strongly Disagree&quot;
## [4] &quot;Neutral&quot; &quot;Strongly Agree&quot; &quot;Neutral&quot;
## [7] &quot;Neutral&quot; &quot;Agree&quot; &quot;Neutral&quot;
## [10] &quot;Disagree&quot; &quot;Disagree&quot; &quot;Agree&quot;
## [13] &quot;Strongly Agree&quot; &quot;Agree&quot; &quot;Neutral&quot;
## [16] &quot;Strongly Disagree&quot; &quot;Strongly Agree&quot; &quot;Neutral&quot;
## [19] &quot;Strongly Disagree&quot; &quot;Strongly Disagree&quot; &quot;Neutral&quot;
## [22] &quot;Neutral&quot; &quot;Strongly Disagree&quot; &quot;Neutral&quot;
## [25] &quot;Disagree&quot; &quot;Agree&quot; &quot;Strongly Agree&quot;
## [28] &quot;Strongly Disagree&quot; &quot;Disagree&quot; &quot;Strongly Disagree&quot;</code></pre>
<p><strong>Bonus / Extra practice</strong>: Let’s say you change your survey so participants can rank their response 1-10 (inclusive). Create a randomly sampled vector of 30 survey responses. (hint use <code>seq()</code> and <code>sample()</code> and set the replace argument to <code>TRUE</code>). Store the output as <code>my_responses_2</code>. Examine the data by typing the name <code>my_responses_2</code> in the Console.</p>
<pre class="r"><code>my_responses_2 &lt;- sample(
x = seq(from = 1, to = 10),
Expand Down
Binary file modified modules/Data_Classes/Data_Classes.pdf
Binary file not shown.
Binary file modified modules/Data_Output/my_environment.RData
Binary file not shown.
34 changes: 17 additions & 17 deletions modules/Data_Visualization/Data_Visualization.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions modules/Factors/Factors.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ <h1 data-config-title><!-- populated from slide_config.json --></h1>
<pre >## [1] yellow red red blue yellow blue
## Levels: blue red yellow</pre>

</article></slide><slide class=""><hgroup><h2>A Factor Example</h2></hgroup><article id="a-factor-example" class="smaller">
</article></slide><slide class=""><hgroup><h2>A Factor Example</h2></hgroup><article class="smaller" id="a-factor-example">

<p>We will use data on student dropouts from the State of California during the 2016-2017 school year. More on this data can be found here: <a href='https://www.cde.ca.gov/ds/ad/filesdropouts.asp' title=''>https://www.cde.ca.gov/ds/ad/filesdropouts.asp</a></p>

Expand Down Expand Up @@ -422,7 +422,7 @@ <h1 data-config-title><!-- populated from slide_config.json --></h1>

<p>Now that’s more like it! Notice how the data is automatically plotted in the order we would like.</p>

</article></slide><slide class=""><hgroup><h2>What about if we <code>arrange()</code> the data by grade ?</h2></hgroup><article id="what-about-if-we-arrange-the-data-by-grade" class="smaller">
</article></slide><slide class=""><hgroup><h2>What about if we <code>arrange()</code> the data by grade ?</h2></hgroup><article class="smaller" id="what-about-if-we-arrange-the-data-by-grade">

<p>Character data is arranged alphabetically.</p>

Expand All @@ -446,7 +446,7 @@ <h1 data-config-title><!-- populated from slide_config.json --></h1>

<p>Notice that the order is not what we would hope for!</p>

</article></slide><slide class=""><hgroup><h2>Arranging Factors</h2></hgroup><article id="arranging-factors" class="smaller">
</article></slide><slide class=""><hgroup><h2>Arranging Factors</h2></hgroup><article class="smaller" id="arranging-factors">

<p>Factor data is arranged by level.</p>

Expand Down Expand Up @@ -502,7 +502,7 @@ <h1 data-config-title><!-- populated from slide_config.json --></h1>
## 3 Junior 2
## 4 Senior 13</pre>

</article></slide><slide class=""><hgroup><h2><code>forcats</code> for ordering</h2></hgroup><article id="forcats-for-ordering" class="smaller">
</article></slide><slide class=""><hgroup><h2><code>forcats</code> for ordering</h2></hgroup><article class="smaller" id="forcats-for-ordering">

<p>What if we wanted to order <code>grade</code> by increasing <code>n_dropouts</code>?</p>

Expand All @@ -517,7 +517,7 @@ <h1 data-config-title><!-- populated from slide_config.json --></h1>

<p>This would be useful for identifying easily which grade to focus on.</p>

</article></slide><slide class=""><hgroup><h2>forcats for ordering</h2></hgroup><article id="forcats-for-ordering-1" class="smaller">
</article></slide><slide class=""><hgroup><h2>forcats for ordering</h2></hgroup><article class="smaller" id="forcats-for-ordering-1">

<p>We can order a factor by another variable by using the <code>fct_reorder()</code> function of the <code>forcats</code> package.</p>

Expand Down Expand Up @@ -552,7 +552,7 @@ <h1 data-config-title><!-- populated from slide_config.json --></h1>
## 5 15633216009179 Junior 0 4
## 6 33670330113647 Sophomore 0 0</pre>

</article></slide><slide class=""><hgroup><h2>Plotting new variable</h2></hgroup><article id="plotting-new-variable" class="smaller">
</article></slide><slide class=""><hgroup><h2>Plotting new variable</h2></hgroup><article class="smaller" id="plotting-new-variable">

<p>Now let’s plot each of our variables of interest (n_dropouts and tardy) on the y axis and grade on the x axis. Let’s arrange grade by the amount of each.</p>

Expand Down
Binary file modified modules/Factors/Factors.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions modules/Functions/Functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ <h1 data-config-title><!-- populated from slide_config.json --></h1>
10 FORD 2000 0 85000 8000
# … with 72,973 more rows</pre>

</article></slide><slide class=""><hgroup><h2>Applying functions with <code>across</code> from <code>dplyr</code></h2></hgroup><article id="applying-functions-with-across-from-dplyr-6" class="smaller">
</article></slide><slide class=""><hgroup><h2>Applying functions with <code>across</code> from <code>dplyr</code></h2></hgroup><article class="smaller" id="applying-functions-with-across-from-dplyr-6">

<p>Combining with <code>mutate()</code> - the <code>replace_na</code> function</p>

Expand Down Expand Up @@ -710,7 +710,7 @@ <h1 data-config-title><!-- populated from slide_config.json --></h1>

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

</article></slide><slide class=""><hgroup><h2>Multiple data frames</h2></hgroup><article id="multiple-data-frames-1" class="smaller">
</article></slide><slide class=""><hgroup><h2>Multiple data frames</h2></hgroup><article class="smaller" id="multiple-data-frames-1">

<p>Lists help us work with multiple data frames</p>

Expand Down
Binary file modified modules/Functions/Functions.pdf
Binary file not shown.
12 changes: 6 additions & 6 deletions modules/Functions/lab/Functions_Lab_Key.html

Large diffs are not rendered by default.

Binary file modified modules/Manipulating_Data_in_R/Manipulating_Data_in_R.pdf
Binary file not shown.
Binary file modified modules/Reproducibility/Reproducibility.pdf
Binary file not shown.
10 changes: 5 additions & 5 deletions modules/Statistics/Statistics.html

Large diffs are not rendered by default.

Binary file modified modules/Subsetting_Data_in_R/Subsetting_Data_in_R.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion modules/Subsetting_Data_in_R/index_withbase.html
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ <h1 data-config-title><!-- populated from slide_config.json --></h1>
{
UseMethod(&quot;filter&quot;)
}
&lt;bytecode: 0x55f94ff62fe0&gt;
&lt;bytecode: 0x55f8804c9f70&gt;
&lt;environment: namespace:dplyr&gt;</pre>

</article></slide><slide class=""><hgroup><h2>Renaming Columns of a <code>data.frame</code>: dplyr</h2></hgroup><article id="renaming-columns-of-a-data.frame-dplyr-2">
Expand Down
Binary file modified modules/cheatsheets/Day-1.pdf
Binary file not shown.
Binary file modified modules/cheatsheets/Day-2.pdf
Binary file not shown.
Binary file modified modules/cheatsheets/Day-3.pdf
Binary file not shown.
Binary file modified modules/cheatsheets/Day-4.pdf
Binary file not shown.
Binary file modified modules/cheatsheets/Day-5.pdf
Binary file not shown.
Binary file modified modules/cheatsheets/Day-6.pdf
Binary file not shown.
Binary file modified modules/cheatsheets/Day-7.pdf
Binary file not shown.
Binary file modified modules/cheatsheets/Day-8.pdf
Binary file not shown.
Binary file modified modules/cheatsheets/Day-9.pdf
Binary file not shown.
64 changes: 32 additions & 32 deletions quotes_vs_backticks.html
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,10 @@ <h2><code>tibble()</code> for naming variables</h2>
## `Number!` `Var with space` `2022` `2021` typical typical2
## &lt;int&gt; &lt;chr&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt;
## 1 1 A 1 4 1 1
## 2 2 B 4 1 2 2
## 3 3 C 3 5 3 3
## 4 4 D 2 2 4 4
## 5 5 E 5 3 5 5</code></pre>
## 2 2 B 2 5 2 2
## 3 3 C 4 3 3 3
## 4 4 D 5 1 4 4
## 5 5 E 3 2 5 5</code></pre>
<pre class="r"><code># this works

ex_data &lt;- tibble(
Expand All @@ -580,11 +580,11 @@ <h2><code>tibble()</code> for naming variables</h2>
<pre><code>## # A tibble: 5 × 6
## `Number!` `Var with space` `2022` `2021` typical typical2
## &lt;int&gt; &lt;chr&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt;
## 1 1 A 5 5 1 1
## 1 1 A 3 4 1 1
## 2 2 B 2 1 2 2
## 3 3 C 4 3 3 3
## 4 4 D 1 2 4 4
## 5 5 E 3 4 5 5</code></pre>
## 3 3 C 1 3 3 3
## 4 4 D 4 5 4 4
## 5 5 E 5 2 5 5</code></pre>
</div>
<div id="rename" class="section level2">
<h2><code>rename()</code></h2>
Expand All @@ -594,32 +594,32 @@ <h2><code>rename()</code></h2>
<pre><code>## # A tibble: 5 × 6
## Number `Var with space` `2022` `2021` typical typical2
## &lt;int&gt; &lt;chr&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt;
## 1 1 A 5 5 1 1
## 1 1 A 3 4 1 1
## 2 2 B 2 1 2 2
## 3 3 C 4 3 3 3
## 4 4 D 1 2 4 4
## 5 5 E 3 4 5 5</code></pre>
## 3 3 C 1 3 3 3
## 4 4 D 4 5 4 4
## 5 5 E 5 2 5 5</code></pre>
<pre class="r"><code>ex_data %&gt;%
rename(Number = &quot;Number!&quot;)</code></pre>
<pre><code>## # A tibble: 5 × 6
## Number `Var with space` `2022` `2021` typical typical2
## &lt;int&gt; &lt;chr&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt;
## 1 1 A 5 5 1 1
## 1 1 A 3 4 1 1
## 2 2 B 2 1 2 2
## 3 3 C 4 3 3 3
## 4 4 D 1 2 4 4
## 5 5 E 3 4 5 5</code></pre>
## 3 3 C 1 3 3 3
## 4 4 D 4 5 4 4
## 5 5 E 5 2 5 5</code></pre>
<pre class="r"><code># not necessary but not problematic to put new typical name in quotes
ex_data %&gt;%
rename(&quot;Number&quot; = &quot;Number!&quot;)</code></pre>
<pre><code>## # A tibble: 5 × 6
## Number `Var with space` `2022` `2021` typical typical2
## &lt;int&gt; &lt;chr&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt;
## 1 1 A 5 5 1 1
## 1 1 A 3 4 1 1
## 2 2 B 2 1 2 2
## 3 3 C 4 3 3 3
## 4 4 D 1 2 4 4
## 5 5 E 3 4 5 5</code></pre>
## 3 3 C 1 3 3 3
## 4 4 D 4 5 4 4
## 5 5 E 5 2 5 5</code></pre>
<p>Here is another example…</p>
<pre class="r"><code># This works because Sepal.Length already exists as a column name. However `new name!` needs backticks because it doesn&#39;t exist yet and R needs to know what it is (not a not equal to conditional for example), as R could interpret it differently.

Expand Down Expand Up @@ -680,29 +680,29 @@ <h2><code>mutate()</code></h2>
<pre><code>## # A tibble: 5 × 6
## `Number!` `Var with space` `2022` `2021` typical typical2
## &lt;dbl&gt; &lt;chr&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt;
## 1 3 A 5 5 1 1
## 1 3 A 3 4 1 1
## 2 4 B 2 1 2 2
## 3 5 C 4 3 3 3
## 4 6 D 1 2 4 4
## 5 7 E 3 4 5 5</code></pre>
## 3 5 C 1 3 3 3
## 4 6 D 4 5 4 4
## 5 7 E 5 2 5 5</code></pre>
<pre class="r"><code>ex_data %&gt;% mutate(&quot;Number!&quot; = `Number!` + 2)</code></pre>
<pre><code>## # A tibble: 5 × 6
## `Number!` `Var with space` `2022` `2021` typical typical2
## &lt;dbl&gt; &lt;chr&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt;
## 1 3 A 5 5 1 1
## 1 3 A 3 4 1 1
## 2 4 B 2 1 2 2
## 3 5 C 4 3 3 3
## 4 6 D 1 2 4 4
## 5 7 E 3 4 5 5</code></pre>
## 3 5 C 1 3 3 3
## 4 6 D 4 5 4 4
## 5 7 E 5 2 5 5</code></pre>
<pre class="r"><code>ex_data %&gt;% mutate(Typical = `Number!` + 2)</code></pre>
<pre><code>## # A tibble: 5 × 7
## `Number!` `Var with space` `2022` `2021` typical typical2 Typical
## &lt;int&gt; &lt;chr&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;dbl&gt;
## 1 1 A 5 5 1 1 3
## 1 1 A 3 4 1 1 3
## 2 2 B 2 1 2 2 4
## 3 3 C 4 3 3 3 5
## 4 4 D 1 2 4 4 6
## 5 5 E 3 4 5 5 7</code></pre>
## 3 3 C 1 3 3 3 5
## 4 4 D 4 5 4 4 6
## 5 5 E 5 2 5 5 7</code></pre>
</div>
<div id="readr-expects-quotes-not-backticks" class="section level2">
<h2><code>readr</code> expects quotes not backticks</h2>
Expand Down
Binary file modified resources/debugging_guide.pdf
Binary file not shown.
Binary file modified resources/good-scientific-coding-practices.pdf
Binary file not shown.
Binary file modified resources/rtools_windows.pdf
Binary file not shown.

0 comments on commit 20302b0

Please sign in to comment.