Skip to content

Commit e8e53dc

Browse files
author
Adam M. Wilson
committed
update cs07
1 parent f2bd66d commit e8e53dc

File tree

23 files changed

+572
-239
lines changed

23 files changed

+572
-239
lines changed

CS_07.Rmd

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ date: 2018-10-10
44
subtitle: Learning more about finding help
55
reading:
66
- How to [write a reproducible example](http://adv-r.had.co.nz/Reproducibility.html)
7+
- Using [Reprex package](https://reprex.tidyverse.org/)
78
presentation:
89
- day_12_help.html
910
tasks:
@@ -33,10 +34,6 @@ md_bullet(rmarkdown::metadata$reading)
3334
md_bullet(rmarkdown::metadata$tasks)
3435
```
3536

36-
## Download
37-
38-
`r output_table()`
39-
4037
## Libraries
4138

4239
```{r purl=F, message=F,warning=FALSE}
@@ -50,9 +47,11 @@ data(world)
5047

5148
## Your problem
5249

53-
You want to make a figure illustrating the distribution of GDP per capita for all countries within each continent using the `world` data in the `spData` package. Your desired figure looks something like the following:
50+
You want to make a figure illustrating the distribution of GDP per capita for all countries within each continent using the `world` data in the `spData` package.
5451

55-
```{r, echo=F, purl=F, warning=F}
52+
### Your goal
53+
Your desired figure looks something like the following:
54+
```{r, echo=F, purl=F, warning=F, fig.width=15}
5655
library(spData)
5756
library(rgdal)
5857
library(sf)
@@ -65,14 +64,37 @@ ggplot(world,aes(x=gdpPercap, fill=continent))+
6564
theme(legend.position = "bottom")
6665
```
6766

67+
### Current Version of your code
6868
You have started working on the figure but can't seem to make it work like you want. Here is your current version of the code (and the resulting figure):
6969

70-
```{r, warning=F}
70+
```{r, warning=F, fig.width=10}
7171
ggplot(world,aes(x=gdpPercap, y=continent, color=continent))+
7272
geom_density(alpha=0.5,color=F)
7373
```
7474

75-
You want to ask for help and so you know that you need to make a reproducible example. Starting with the code above, make the required edits so you can use `reprex()` to generate a nicely formatted example that you could email or post to a forum to ask for help. See the [reading](https://reprex.tidyverse.org/) for more help. Note: you do _not_ need to recreate the figure above, only to use `reprex()` to illustrate your question.
75+
The second figure is quite different from the one you want. You want to ask for help and so you know that you need to make a reproducible example. Starting with the code above, make the required edits so you can use `reprex()` to generate a nicely formatted example that you could email or post to a forum to ask for help. See the [reading](https://reprex.tidyverse.org/) for more help. Note: you do _not_ need to recreate the first figure above, only to use `reprex()` to illustrate your question and problematic code.
76+
77+
<div class="well">
78+
<button data-toggle="collapse" class="btn btn-primary btn-sm round" data-target="#demo1">Show Hints</button>
79+
<div id="demo1" class="collapse">
80+
81+
## Steps
82+
1. Download the [<i class="fa fa-file-code-o fa-1x" aria-hidden="true"></i> starter R script (if desired)](`r output_nocomment`){target="_blank"}. Save this directly to your course folder (repository) so you don't lose track of it!
83+
2. Add code needed to produce the second plot (loading required libraries above and loading the `world` data)
84+
2. Copy the code to your clipboard
85+
3. run `reprex()` to generate the reproducible example in the "Viewer Pane"
86+
4. Export the preview as an html file and save it in your course repository. It should look something like this (note the image is intentionally blurred):
87+
![](assets/reprex.png)
88+
89+
</div>
90+
</div>
7691

77-
If you have extra time, try to fix the code above to make the first figure.
7892

93+
<div class="extraswell">
94+
<button data-toggle="collapse" class="btn btn-link" data-target="#extras">
95+
Extra time? Try this...
96+
</button>
97+
<div id="extras" class="collapse">
98+
Fix the code above to recreate the first figure.
99+
</div>
100+
</div>

CS_07.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ date: 2018-10-10
44
subtitle: Learning more about finding help
55
reading:
66
- How to [write a reproducible example](http://adv-r.had.co.nz/Reproducibility.html)
7+
- Using [Reprex package](https://reprex.tidyverse.org/)
78
presentation:
89
- day_12_help.html
910
tasks:
@@ -41,11 +42,6 @@ tasks:
4142
- Debug existing code
4243
- Save your reprex to your course repository as an html file using Export -> "Save As Webpage" in the RStudio "Viewer" Tab.
4344

44-
## Download
45-
46-
| [<i class='fas fa-code fa-2x' aria-hidden='true'></i><br> R Script]( scripts/CS_07_nocomments.R ) | [<i class='fa fa-file-code-o fa-2x'></i> <br> Commented R Script]( scripts/CS_07.R ) | [<i class='far fa-file-alt fa-2x'></i> <br> Rmd Script]( scripts/CS_07.Rmd )|
47-
|:--:|:-:|:-:|
48-
4945
## Libraries
5046

5147

@@ -60,10 +56,13 @@ data(world)
6056

6157
## Your problem
6258

63-
You want to make a figure illustrating the distribution of GDP per capita for all countries within each continent using the `world` data in the `spData` package. Your desired figure looks something like the following:
59+
You want to make a figure illustrating the distribution of GDP per capita for all countries within each continent using the `world` data in the `spData` package.
6460

61+
### Your goal
62+
Your desired figure looks something like the following:
6563
![](CS_07_files/figure-html/unnamed-chunk-3-1.png)<!-- -->
6664

65+
### Current Version of your code
6766
You have started working on the figure but can't seem to make it work like you want. Here is your current version of the code (and the resulting figure):
6867

6968

@@ -74,7 +73,29 @@ ggplot(world,aes(x=gdpPercap, y=continent, color=continent))+
7473

7574
![](CS_07_files/figure-html/unnamed-chunk-4-1.png)<!-- -->
7675

77-
You want to ask for help and so you know that you need to make a reproducible example. Starting with the code above, make the required edits so you can use `reprex()` to generate a nicely formatted example that you could email or post to a forum to ask for help. See the [reading](https://reprex.tidyverse.org/) for more help. Note: you do _not_ need to recreate the figure above, only to use `reprex()` to illustrate your question.
76+
The second figure is quite different from the one you want. You want to ask for help and so you know that you need to make a reproducible example. Starting with the code above, make the required edits so you can use `reprex()` to generate a nicely formatted example that you could email or post to a forum to ask for help. See the [reading](https://reprex.tidyverse.org/) for more help. Note: you do _not_ need to recreate the first figure above, only to use `reprex()` to illustrate your question and problematic code.
77+
78+
<div class="well">
79+
<button data-toggle="collapse" class="btn btn-primary btn-sm round" data-target="#demo1">Show Hints</button>
80+
<div id="demo1" class="collapse">
7881

79-
If you have extra time, try to fix the code above to make the first figure.
82+
## Steps
83+
1. Download the [<i class="fa fa-file-code-o fa-1x" aria-hidden="true"></i> starter R script (if desired)](scripts/CS_07_nocomments.R){target="_blank"}. Save this directly to your course folder (repository) so you don't lose track of it!
84+
2. Add code needed to produce the second plot (loading required libraries above and loading the `world` data)
85+
2. Copy the code to your clipboard
86+
3. run `reprex()` to generate the reproducible example in the "Viewer Pane"
87+
4. Export the preview as an html file and save it in your course repository. It should look something like this (note the image is intentionally blurred):
88+
![](assets/reprex.png)
8089

90+
</div>
91+
</div>
92+
93+
94+
<div class="extraswell">
95+
<button data-toggle="collapse" class="btn btn-link" data-target="#extras">
96+
Extra time? Try this...
97+
</button>
98+
<div id="extras" class="collapse">
99+
Fix the code above to recreate the first figure.
100+
</div>
101+
</div>
70.8 KB
Loading
21 KB
Loading

Tasklist.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ ___
166166
<a class="btn btn-link" href="./CS_07.html" role="button" >Full Description</a><button data-toggle="collapse" class="btn btn-link" data-target="#i9">Preview Readings & Tasks </button><div id="i9" class="collapse">
167167
## Readings
168168
- How to [write a reproducible example](http://adv-r.had.co.nz/Reproducibility.html)
169+
- Using [Reprex package](https://reprex.tidyverse.org/)
169170

170171
## Tasks
171172
- Learn how to read R help files effectively

assets/reprex.png

87.1 KB
Loading

docs/CS_07.html

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -441,20 +441,6 @@ <h1>Tasks</h1>
441441
<li>Debug existing code</li>
442442
<li>Save your reprex to your course repository as an html file using Export -&gt; “Save As Webpage” in the RStudio “Viewer” Tab.</li>
443443
</ul>
444-
<div id="download" class="section level2">
445-
<h2>Download</h2>
446-
<table>
447-
<thead>
448-
<tr class="header">
449-
<th align="center"><a href="scripts/CS_07_nocomments.R"><i class='fas fa-code fa-2x' aria-hidden='true'></i><br> R Script</a></th>
450-
<th align="center"><a href="scripts/CS_07.R"><i class='fa fa-file-code-o fa-2x'></i> <br> Commented R Script</a></th>
451-
<th align="center"><a href="scripts/CS_07.Rmd"><i class='far fa-file-alt fa-2x'></i> <br> Rmd Script</a></th>
452-
</tr>
453-
</thead>
454-
<tbody>
455-
</tbody>
456-
</table>
457-
</div>
458444
<div id="libraries" class="section level2">
459445
<h2>Libraries</h2>
460446
<pre class="r"><code>library(tidyverse)
@@ -466,14 +452,42 @@ <h2>Libraries</h2>
466452
</div>
467453
<div id="your-problem" class="section level2">
468454
<h2>Your problem</h2>
469-
<p>You want to make a figure illustrating the distribution of GDP per capita for all countries within each continent using the <code>world</code> data in the <code>spData</code> package. Your desired figure looks something like the following:</p>
470-
<p><img src="CS_07_files/figure-html/unnamed-chunk-3-1.png" /><!-- --></p>
455+
<p>You want to make a figure illustrating the distribution of GDP per capita for all countries within each continent using the <code>world</code> data in the <code>spData</code> package.</p>
456+
<div id="your-goal" class="section level3">
457+
<h3>Your goal</h3>
458+
<p>Your desired figure looks something like the following: <img src="CS_07_files/figure-html/unnamed-chunk-3-1.png" /><!-- --></p>
459+
</div>
460+
<div id="current-version-of-your-code" class="section level3">
461+
<h3>Current Version of your code</h3>
471462
<p>You have started working on the figure but can’t seem to make it work like you want. Here is your current version of the code (and the resulting figure):</p>
472463
<pre class="r"><code>ggplot(world,aes(x=gdpPercap, y=continent, color=continent))+
473464
geom_density(alpha=0.5,color=F)</code></pre>
474465
<p><img src="CS_07_files/figure-html/unnamed-chunk-4-1.png" /><!-- --></p>
475-
<p>You want to ask for help and so you know that you need to make a reproducible example. Starting with the code above, make the required edits so you can use <code>reprex()</code> to generate a nicely formatted example that you could email or post to a forum to ask for help. See the <a href="https://reprex.tidyverse.org/">reading</a> for more help. Note: you do <em>not</em> need to recreate the figure above, only to use <code>reprex()</code> to illustrate your question.</p>
476-
<p>If you have extra time, try to fix the code above to make the first figure.</p>
466+
<p>The second figure is quite different from the one you want. You want to ask for help and so you know that you need to make a reproducible example. Starting with the code above, make the required edits so you can use <code>reprex()</code> to generate a nicely formatted example that you could email or post to a forum to ask for help. See the <a href="https://reprex.tidyverse.org/">reading</a> for more help. Note: you do <em>not</em> need to recreate the first figure above, only to use <code>reprex()</code> to illustrate your question and problematic code.</p>
467+
<div class="well">
468+
<button data-toggle="collapse" class="btn btn-primary btn-sm round" data-target="#demo1">
469+
Show Hints
470+
</button>
471+
<div id="demo1" class="collapse">
472+
<h2 id="steps">Steps</h2>
473+
<ol style="list-style-type: decimal">
474+
<li>Download the <a href="scripts/CS_07_nocomments.R" target="_blank"><i class="fa fa-file-code-o fa-1x" aria-hidden="true"></i> starter R script (if desired)</a>. Save this directly to your course folder (repository) so you don’t lose track of it!</li>
475+
<li>Add code needed to produce the second plot (loading required libraries above and loading the <code>world</code> data)</li>
476+
<li>Copy the code to your clipboard</li>
477+
<li>run <code>reprex()</code> to generate the reproducible example in the “Viewer Pane”</li>
478+
<li>Export the preview as an html file and save it in your course repository. It should look something like this (note the image is intentionally blurred): <img src="assets/reprex.png" /></li>
479+
</ol>
480+
</div>
481+
</div>
482+
<div class="extraswell">
483+
<button data-toggle="collapse" class="btn btn-link" data-target="#extras">
484+
Extra time? Try this…
485+
</button>
486+
<div id="extras" class="collapse">
487+
<p>Fix the code above to recreate the first figure.</p>
488+
</div>
489+
</div>
490+
</div>
477491
</div>
478492
</div>
479493

70.8 KB
Loading
21 KB
Loading

docs/Tasklist.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ <h1><a href="./CS_07.html">CS_07 : Getting Help!</a></h1>
603603
<h2 id="readings-8">Readings</h2>
604604
<ul>
605605
<li>How to <a href="http://adv-r.had.co.nz/Reproducibility.html">write a reproducible example</a></li>
606+
<li>Using <a href="https://reprex.tidyverse.org/">Reprex package</a></li>
606607
</ul>
607608
<h2 id="tasks-8">Tasks</h2>
608609
<ul>

0 commit comments

Comments
 (0)