Skip to content

Commit

Permalink
"Test Your Understanding" section moved to end of notes
Browse files Browse the repository at this point in the history
  • Loading branch information
katieburak committed Aug 23, 2024
1 parent 4f0d14a commit d661c5a
Show file tree
Hide file tree
Showing 34 changed files with 273 additions and 250 deletions.
2 changes: 1 addition & 1 deletion content/course.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Options for working on these worksheets:

*Submit the worksheets by uploading your .ipynb file to the corresponding canvas assignment slot*.

*To get full marks for each participation worksheet, you must successfully answer at least 50% of all autograded questions.*
*To get full marks for each formative worksheet, you must successfully answer at least 50% of all autograded questions.*

### Part A

Expand Down
12 changes: 6 additions & 6 deletions content/notes/notes-a02.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ Some additional resources that you might find useful:

- Read the [Understanding the GitHub flow](https://guides.github.com/introduction/flow/) to get a sense of branching.

## Test Your Understanding

1. You've just successfully pushed your branch to GitHub! True or False: it's still possible for the branch on GitHub to contain work that's not on your computer.
2. You're ready to push some code you added to `code.R` to GitHub, but just found out that your teammate completely changed `code.R` on GitHub! True or False: If you pull the repository from GitHub, you'll get an error because your `code.R` conflicts with GitHub's `code.R`.
3. True or False: If you've just changed a file on your computer, in order to push it to GitHub, you'll first need to commit the file.

<!-- ## Version control: what is it, and why should you care? -->

<!-- Version control software systematically records changes to a set of files over time, and allows us to summon and compare any version of these files that was recorded on demand. -->
Expand Down Expand Up @@ -142,6 +136,12 @@ STAT 777 @ UBC

4. Save and commit the file. (An informative message here might be "Fixing a merge conflict.") You should now be able to successfully push!

## Test Your Understanding

1. You've just successfully pushed your branch to GitHub! True or False: it's still possible for the branch on GitHub to contain work that's not on your computer.
2. You're ready to push some code you added to `code.R` to GitHub, but just found out that your teammate completely changed `code.R` on GitHub! True or False: If you pull the repository from GitHub, you'll get an error because your `code.R` conflicts with GitHub's `code.R`.
3. True or False: If you've just changed a file on your computer, in order to push it to GitHub, you'll first need to commit the file.

---

### Your turn: Branching, merging, and pull requests
Expand Down
16 changes: 8 additions & 8 deletions content/notes/notes-a02.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ <h2>Resources</h2>
<ul>
<li>Read the <a href="https://guides.github.com/introduction/flow/">Understanding the GitHub flow</a> to get a sense of branching.</li>
</ul>
</div>
<div id="test-your-understanding" class="section level2">
<h2>Test Your Understanding</h2>
<ol style="list-style-type: decimal">
<li>You’ve just successfully pushed your branch to GitHub! True or False: it’s still possible for the branch on GitHub to contain work that’s not on your computer.</li>
<li>You’re ready to push some code you added to <code>code.R</code> to GitHub, but just found out that your teammate completely changed <code>code.R</code> on GitHub! True or False: If you pull the repository from GitHub, you’ll get an error because your <code>code.R</code> conflicts with GitHub’s <code>code.R</code>.</li>
<li>True or False: If you’ve just changed a file on your computer, in order to push it to GitHub, you’ll first need to commit the file.</li>
</ol>
<!-- ## Version control: what is it, and why should you care? -->
<!-- Version control software systematically records changes to a set of files over time, and allows us to summon and compare any version of these files that was recorded on demand. -->
<!-- Version control is super useful for code, because we frequently draft code that doesn't work. It's nice to be able to save what works before you start making changes - then if you really get lost, you can revert back to a working version of your code. -->
Expand Down Expand Up @@ -124,6 +116,14 @@ <h2>Instructor demo: merge conflicts</h2>
<li><p>The stuff below the <code>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</code> and above the <code>=======</code> is what was in your local version; the stuff above the <code>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</code> and below the <code>=======</code> is what was in the remote conflicting version. Decide what you want to have on the offending line (e.g. “STAT 555 @ UBC), and replace the whole block of text above with that.</p></li>
<li><p>Save and commit the file. (An informative message here might be “Fixing a merge conflict.”) You should now be able to successfully push!</p></li>
</ol>
</div>
<div id="test-your-understanding" class="section level2">
<h2>Test Your Understanding</h2>
<ol style="list-style-type: decimal">
<li>You’ve just successfully pushed your branch to GitHub! True or False: it’s still possible for the branch on GitHub to contain work that’s not on your computer.</li>
<li>You’re ready to push some code you added to <code>code.R</code> to GitHub, but just found out that your teammate completely changed <code>code.R</code> on GitHub! True or False: If you pull the repository from GitHub, you’ll get an error because your <code>code.R</code> conflicts with GitHub’s <code>code.R</code>.</li>
<li>True or False: If you’ve just changed a file on your computer, in order to push it to GitHub, you’ll first need to commit the file.</li>
</ol>
<hr />
<div id="your-turn-branching-merging-and-pull-requests" class="section level3">
<h3>Your turn: Branching, merging, and pull requests</h3>
Expand Down
10 changes: 5 additions & 5 deletions content/notes/notes-a03/index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ Others:

- An entertaining and concise argument against using "WYSIWYG" editors like Microsoft Word.

## Test Your Understanding

1. True or False: It doesn't make sense to output an .Rmd file to markdown, because .Rmd is already markdown.
2. Which of these file formats are proprietary? (a) `.docx`; (b) `.html`; (c) `.txt`; (d) `.Rmd`; (e) `.xlsx`

## Reproducible data analysis

Let's say we have some data analysis results, like a figure or a table. We would say these results are *reproducible* if we could produce the same results by using the same data and code.
Expand Down Expand Up @@ -175,6 +170,11 @@ Just like YAML is metadata for the Rmd document, *code chunk options* are metada

3. Knit the results. Can you spot the differences?

## Test Your Understanding

1. True or False: It doesn't make sense to output an .Rmd file to markdown, because .Rmd is already markdown.
2. Which of these file formats are proprietary? (a) `.docx`; (b) `.html`; (c) `.txt`; (d) `.Rmd`; (e) `.xlsx`

---

### Your turn: data update!
Expand Down
16 changes: 8 additions & 8 deletions content/notes/notes-a03/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ <h2>Resources</h2>
</ul></li>
</ul>
</div>
<div id="test-your-understanding" class="section level2">
<h2>Test Your Understanding</h2>
<ol style="list-style-type: decimal">
<li>True or False: It doesn’t make sense to output an .Rmd file to markdown, because .Rmd is already markdown.</li>
<li>Which of these file formats are proprietary? (a) <code>.docx</code>; (b) <code>.html</code>; (c) <code>.txt</code>; (d) <code>.Rmd</code>; (e) <code>.xlsx</code></li>
</ol>
</div>
<div id="reproducible-data-analysis" class="section level2">
<h2>Reproducible data analysis</h2>
<p>Let’s say we have some data analysis results, like a figure or a table. We would say these results are <em>reproducible</em> if we could produce the same results by using the same data and code.</p>
Expand Down Expand Up @@ -147,9 +140,16 @@ <h4>Exploring chunk options</h4>
<li><p>Change the figure width and height with <code>fig.width = 5</code> and <code>fig.height = 3</code>.</p></li>
<li><p>Knit the results. Can you spot the differences?</p></li>
</ol>
<hr />
</div>
</div>
</div>
<div id="test-your-understanding" class="section level2">
<h2>Test Your Understanding</h2>
<ol style="list-style-type: decimal">
<li>True or False: It doesn’t make sense to output an .Rmd file to markdown, because .Rmd is already markdown.</li>
<li>Which of these file formats are proprietary? (a) <code>.docx</code>; (b) <code>.html</code>; (c) <code>.txt</code>; (d) <code>.Rmd</code>; (e) <code>.xlsx</code></li>
</ol>
<hr />
<div id="your-turn-data-update" class="section level3">
<h3>Your turn: data update!</h3>
<p>In the instructor demo, we prettied up a nice report about <code>mtcars</code> together. But suddenly, you receive an email from your collaborator who collected the <code>mtcars</code> data, who says that the data on Mazda RX4, the Valiant, and the Volvo 142E were transcribed wrong from the magazine! They’re going to work on correcting them, but in the mean time, they’d like to re-run the analysis with those three cars excluded.</p>
Expand Down
16 changes: 9 additions & 7 deletions content/notes/notes-a04.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ Optional further reading to learn about the `across()` function:

- [Hadley Wickham's blog post on the topic](https://www.tidyverse.org/blog/2020/04/dplyr-1-0-0-colwise/).

## Test Your Understanding

1. True or False? Running filter or select on your tibble permanently changes your tibble.
2. True or False? The pipe operator `%>%` works for functions outside of the tidyverse, too.
3. True or False? `summarise()` reduces each group down to one row, and `mutate()` preserves the number of rows. But, between the two, there's a way to reduce each group down to _two_ rows.
4. True or False? `across()` doesn't allow you to make new column names.

## Why Data Manipulation?

You have a shiny new data set - great! You might be tempted to dive right in and start making pretty graphs and fitting cool models to your data. Not so fast! In practice, it's very rare that you have the data in the exact right form to make the graph you want, or fit the model you want. You will need to start by *manipulating* your data into the right form: creating new variables, subsetting rows, renaming columns, etc.
Expand All @@ -53,6 +46,15 @@ An even less sexy but perhaps even more important part of data analysis is simpl

All of these require data manipulation. We choose to use the `dplyr` (pronounced d-plier) package for this.

## Test Your Understanding

1. True or False? Running filter or select on your tibble permanently changes your tibble.
2. True or False? The pipe operator `%>%` works for functions outside of the tidyverse, too.
3. True or False? `summarise()` reduces each group down to one row, and `mutate()` preserves the number of rows. But, between the two, there's a way to reduce each group down to _two_ rows.
4. True or False? `across()` doesn't allow you to make new column names.

---

## Your turn: learning to use dplyr

We think the best way to learn the basics of dplyr is to work through Worksheet A2.
Expand Down
19 changes: 10 additions & 9 deletions content/notes/notes-a04.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ <h2>Resources</h2>
<li><a href="https://www.tidyverse.org/blog/2020/04/dplyr-1-0-0-colwise/">Hadley Wickham’s blog post on the topic</a>.</li>
</ul>
</div>
<div id="test-your-understanding" class="section level2">
<h2>Test Your Understanding</h2>
<ol style="list-style-type: decimal">
<li>True or False? Running filter or select on your tibble permanently changes your tibble.</li>
<li>True or False? The pipe operator <code>%&gt;%</code> works for functions outside of the tidyverse, too.</li>
<li>True or False? <code>summarise()</code> reduces each group down to one row, and <code>mutate()</code> preserves the number of rows. But, between the two, there’s a way to reduce each group down to <em>two</em> rows.</li>
<li>True or False? <code>across()</code> doesn’t allow you to make new column names.</li>
</ol>
</div>
<div id="why-data-manipulation" class="section level2">
<h2>Why Data Manipulation?</h2>
<p>You have a shiny new data set - great! You might be tempted to dive right in and start making pretty graphs and fitting cool models to your data. Not so fast! In practice, it’s very rare that you have the data in the exact right form to make the graph you want, or fit the model you want. You will need to start by <em>manipulating</em> your data into the right form: creating new variables, subsetting rows, renaming columns, etc.</p>
Expand All @@ -58,6 +49,16 @@ <h2>Why Data Manipulation?</h2>
</ul>
<p>All of these require data manipulation. We choose to use the <code>dplyr</code> (pronounced d-plier) package for this.</p>
</div>
<div id="test-your-understanding" class="section level2">
<h2>Test Your Understanding</h2>
<ol style="list-style-type: decimal">
<li>True or False? Running filter or select on your tibble permanently changes your tibble.</li>
<li>True or False? The pipe operator <code>%&gt;%</code> works for functions outside of the tidyverse, too.</li>
<li>True or False? <code>summarise()</code> reduces each group down to one row, and <code>mutate()</code> preserves the number of rows. But, between the two, there’s a way to reduce each group down to <em>two</em> rows.</li>
<li>True or False? <code>across()</code> doesn’t allow you to make new column names.</li>
</ol>
<hr />
</div>
<div id="your-turn-learning-to-use-dplyr" class="section level2">
<h2>Your turn: learning to use dplyr</h2>
<p>We think the best way to learn the basics of dplyr is to work through Worksheet A2.</p>
Expand Down
16 changes: 9 additions & 7 deletions content/notes/notes-a06.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ Resources about producing effective visualizations:
- Vincenzo's ["Communicating data" slides](https://vincenzocoia.com/communicating_data/#1) provide some rules of thumb.
- [Callingbull.org's entry on visualizations](https://www.callingbull.org/tools/tools_misleading_axes.html), by Carl T. Bergstrom and Jevin West, goes over several examples of improving ineffective visuals.

## Test Your Understanding

1. True or False: You can re-specify global aesthetics by adding an `aes()` layer to a ggplot object.
2. True or False: With ggplot2, we can specify the data in a geom layer, in addition to the initial `ggplot()` layer.
3. True or False: Because the `dplyr::group_by()` function and ggplot2's `group` aesthetic both split a tibble into groups, we can use either one when making a plot.
4. True or False: In principle, mapping `continent` to letters (a, b, c, ...) is an aesthetic mapping.

## Why Plotting?

The human visual cortex is a powerful thing. If you're wanting to point someone's attention to a bunch of numbers, I can assure you that you won't elicit any "aha" moments by displaying those numbers in a table, either in a report or (especially!) a presentation. Turn those numbers into a plot, and suddenly you can see patterns and relationships.
Expand Down Expand Up @@ -182,6 +175,15 @@ ggplot(gapminder, aes(gdpPercap, lifeExp)) +
ylab("Life Expectancy")
```

## Test Your Understanding

1. True or False: You can re-specify global aesthetics by adding an `aes()` layer to a ggplot object.
2. True or False: With ggplot2, we can specify the data in a geom layer, in addition to the initial `ggplot()` layer.
3. True or False: Because the `dplyr::group_by()` function and ggplot2's `group` aesthetic both split a tibble into groups, we can use either one when making a plot.
4. True or False: In principle, mapping `continent` to letters (a, b, c, ...) is an aesthetic mapping.

---

## Your turn: learning to use ggplot2

We think the best way to learn the basics of ggplot2 is to work through Worksheet A3.
Expand Down
55 changes: 31 additions & 24 deletions content/notes/notes-a06.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,6 @@ <h2>Resources</h2>
</ul></li>
</ul>
</div>
<div id="test-your-understanding" class="section level2">
<h2>Test Your Understanding</h2>
<ol style="list-style-type: decimal">
<li>True or False: You can re-specify global aesthetics by adding an <code>aes()</code> layer to a ggplot object.</li>
<li>True or False: With ggplot2, we can specify the data in a geom layer, in addition to the initial <code>ggplot()</code> layer.</li>
<li>True or False: Because the <code>dplyr::group_by()</code> function and ggplot2’s <code>group</code> aesthetic both split a tibble into groups, we can use either one when making a plot.</li>
<li>True or False: In principle, mapping <code>continent</code> to letters (a, b, c, …) is an aesthetic mapping.</li>
</ol>
</div>
<div id="why-plotting" class="section level2">
<h2>Why Plotting?</h2>
<p>The human visual cortex is a powerful thing. If you’re wanting to point someone’s attention to a bunch of numbers, I can assure you that you won’t elicit any “aha” moments by displaying those numbers in a table, either in a report or (especially!) a presentation. Turn those numbers into a plot, and suddenly you can see patterns and relationships.</p>
Expand Down Expand Up @@ -127,37 +118,37 @@ <h3>Example: Scatterplot grammar</h3>
<p>This scatterplot has the following grammar components:</p>
<table>
<thead>
<tr class="header">
<tr>
<th>Grammar Component</th>
<th>Specification</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<tr>
<td><strong>data</strong></td>
<td><code>gapminder</code></td>
</tr>
<tr class="even">
<tr>
<td><strong>aesthetic mapping</strong></td>
<td><strong>x</strong>: <code>gdpPercap</code>, <strong>y:</strong> <code>lifeExp</code></td>
</tr>
<tr class="odd">
<tr>
<td><strong>geometric object</strong></td>
<td>points</td>
</tr>
<tr class="even">
<tr>
<td>scale</td>
<td>x: log10, y: linear</td>
</tr>
<tr class="odd">
<tr>
<td>statistical transform</td>
<td>none</td>
</tr>
<tr class="even">
<tr>
<td>coordinate system</td>
<td>rectangular</td>
</tr>
<tr class="odd">
<tr>
<td>facetting</td>
<td>none</td>
</tr>
Expand Down Expand Up @@ -198,6 +189,16 @@ <h2>Example: your first ggplot2 plot</h2>
ylab(&quot;Life Expectancy&quot;)</code></pre>
<p><img src="/notes/notes-a06_files/figure-html/unnamed-chunk-7-1.png" width="480" style="display: block; margin: auto;" /></p>
</div>
<div id="test-your-understanding" class="section level2">
<h2>Test Your Understanding</h2>
<ol style="list-style-type: decimal">
<li>True or False: You can re-specify global aesthetics by adding an <code>aes()</code> layer to a ggplot object.</li>
<li>True or False: With ggplot2, we can specify the data in a geom layer, in addition to the initial <code>ggplot()</code> layer.</li>
<li>True or False: Because the <code>dplyr::group_by()</code> function and ggplot2’s <code>group</code> aesthetic both split a tibble into groups, we can use either one when making a plot.</li>
<li>True or False: In principle, mapping <code>continent</code> to letters (a, b, c, …) is an aesthetic mapping.</li>
</ol>
<hr />
</div>
<div id="your-turn-learning-to-use-ggplot2" class="section level2">
<h2>Your turn: learning to use ggplot2</h2>
<p>We think the best way to learn the basics of ggplot2 is to work through Worksheet A3.</p>
Expand Down Expand Up @@ -240,7 +241,7 @@ <h2>Class 2: FEV Case Study</h2>
Example:
```r
``` r
ggplot(gapminder, aes(lifeExp)) +
geom_histogram(bins = 50)
```
Expand All @@ -263,7 +264,7 @@ <h2>Class 2: FEV Case Study</h2>
Example:
```r
``` r
ggplot(gapminder, aes(lifeExp)) +
geom_density()
```
Expand All @@ -282,7 +283,7 @@ <h2>Class 2: FEV Case Study</h2>
Example:
```r
``` r
ggplot(gapminder, aes(continent, lifeExp)) +
geom_jitter()
```
Expand All @@ -301,7 +302,7 @@ <h2>Class 2: FEV Case Study</h2>
Example:
```r
``` r
ggplot(gapminder, aes(continent, lifeExp)) +
geom_boxplot()
```
Expand All @@ -323,7 +324,7 @@ <h2>Class 2: FEV Case Study</h2>
Example:
```r
``` r
ggplot(gapminder, aes(lifeExp, continent)) +
ggridges::geom_density_ridges()
```
Expand Down Expand Up @@ -351,7 +352,7 @@ <h2>Class 2: FEV Case Study</h2>
Example: number of 4-, 6-, and 8- cylinder cars in the `mtcars` dataset:
```r
``` r
ggplot(mtcars, aes(cyl)) +
geom_bar()
```
Expand All @@ -370,7 +371,7 @@ <h2>Class 2: FEV Case Study</h2>
Although not required, the `group` aesthetic will come in handy here. This aesthetic produces a plot independently for each group, and overlays the results.
```r
``` r
tsibble::as_tsibble(co2) %>%
rename(yearmonth = index,
conc = value) %>%
Expand All @@ -381,6 +382,12 @@ <h2>Class 2: FEV Case Study</h2>
ylab("CO2 Concentration")
```
```
## Registered S3 method overwritten by 'tsibble':
## method from
## as_tibble.grouped_df dplyr
```
<img src="/notes/notes-a06_files/figure-html/unnamed-chunk-14-1.png" width="480" style="display: block; margin: auto;" />
Expand Down
Loading

0 comments on commit d661c5a

Please sign in to comment.