Skip to content

Commit

Permalink
Revisited remaining slide decks (6A, 7A-B, and 8A) and made minor typ…
Browse files Browse the repository at this point in the history
…o fixes/clarity improvements
  • Loading branch information
njlyon0 committed Jul 3, 2024
1 parent da4de58 commit ea712a8
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 89 deletions.
4 changes: 2 additions & 2 deletions _freeze/materials/slides_6b/execute-results/html.json

Large diffs are not rendered by default.

Binary file modified _freeze/materials/slides_6b/figure-revealjs/ex-graph-v12-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions _freeze/materials/slides_7a/execute-results/html.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions _freeze/materials/slides_7b/execute-results/html.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"hash": "6c71a5a140067a001ce0f4ba12b2a062",
"hash": "a3aa4665f1039c1a020f60e56012191a",
"result": {
"engine": "knitr",
"markdown": "---\ntitle: \"Intro to Data Science\"\nauthor: \"Lab 7 -- Function Tutorials (Draft 2)\"\nengine: knitr\nformat: \n revealjs: \n slide-number: c\n scrollable: false\n code-overflow: wrap\n code-line-numbers: false\n code-copy: hover\n theme: [night, slides.scss]\n reference-location: document\n footer: \"[Programming in R for Biologists](https://njlyon0.github.io/teach_r-for-biologists/)\"\n---\n\n\n## A Guide to Your Process\n\n### [Scheduling]{.blue}\n\n### [Learning Objectives]{.purple}\n\n### [Practice]{.pink}\n\n### [Supporting Information]{.orange}\n\n### [Class Discussion]{.gold}\n\n## [Today's Plan]{.blue}\n\n- Muddiest Point Review\n- Create New Feedback Surveys\n- Function Tutorials – Draft 2 Presentations\n\n## [Today's Learning Objectives]{.purple}\n\nAfter today's session you will be able to:\n\n. . .\n\n- Demonstrate integration of feedback\n- Refine a feedback survey\n- Explain R functions to an audience of your peers\n - Even more confidently!\n\n\n## [Muddiest Point Review]{.gold}\n\n- Recurring topics from most recent MPs:\n\n\\\n\n. . .\n\n- What other topic(s) would you like to review?\n\n## [Create a Google Form]{.pink} {.smaller}\n\n- Consult [Lab \\#5]{.blue} slides for a refresher on making Google Forms\n\n\\\n\n- Make a new Google Form for peer feedback today\n - Remember to add me to the editing side!\n\n\\\n\n- Your form should have (at least):\n - Paragraph about whether people feel you addressed their feedback from [Draft 1]{.pink}\n - Any questions from first survey that you think are still valuable\n\n## [Feedback Reminder]{.orange}\n\nKeep the following pieces of advice in mind:\n\n\\\n\n. . .\n\n1. Be specific and reasonable!\n\n\\\n\n2. Pair critiques with positive comments\n\n\\\n\n3. Be constructively critical\n\n## [Temperature Check]{.purple}\n\n#### How are you Feeling?\n\n<p align=\"center\">\n<img src=\"comics/debugging.png\" alt=\"Comic-style graph depicting someone's emotional state as they debug code (from initial struggle and defeat to eventual triumph)\">\n</p>\n\n\n## [Get Ready]{.pink} {.smaller}\n\n- Find & knit your R Markdown file, then open the product\n\n\\\n\n- Take a deep breath and relax!\n - You got this!\n\n\\\n\n- Let me know when you're ready\n\n## [Revised Function Tutorials]{.orange} {.smaller}\n\n- Something to keep in mind:\n - There is an <u>optional</u> 3^rd^ draft! \n - If you submit draft 3 and do better than draft 2, [it will replace your score]{.gold}\n - So take feedback seriously just in case you're unhappy with your draft 2 points!\n\n\\\n\n. . . \n\n- Anyone want to volunteer to go first?\n - I'll pick order randomly if there are no volunteers\n\n## [Temperature Check]{.purple}\n\n#### How are you Feeling?\n\n<p align=\"center\">\n<img src=\"comics/debugging.png\" alt=\"Comic-style graph depicting someone's emotional state as they debug code (from initial struggle and defeat to eventual triumph)\">\n</p>\n\n## [Upcoming Due Dates]{.blue} {.smaller}\n\n::::{.columns}\n:::{.column width=\"50%\"}\n\n### Due before lecture\n\n#### (By midnight)\n\n- Homework \\#7\n\n:::\n:::{.column width=\"50%\"}\n\n### Due before lab\n\n#### (By midnight)\n\n- Muddiest Point \\#8\n- Homework \\#8\n - Note reduced time to complete for this one!\n- GitHub Presence evaluation\n- _Optional_ 3^rd^ draft of Function Tutorials\n\n:::\n::::\n",
"markdown": "---\ntitle: \"Intro to Data Science\"\nauthor: \"Lab 7 -- Function Tutorials (Draft 2)\"\nengine: knitr\nformat: \n revealjs: \n slide-number: c\n scrollable: false\n code-overflow: wrap\n code-line-numbers: false\n code-copy: hover\n theme: [night, slides.scss]\n reference-location: document\n footer: \"[Programming in R for Biologists](https://njlyon0.github.io/teach_r-for-biologists/)\"\n---\n\n\n## A Guide to Your Process\n\n### [Scheduling]{.blue}\n\n### [Learning Objectives]{.purple}\n\n### [Practice]{.pink}\n\n### [Supporting Information]{.orange}\n\n### [Class Discussion]{.gold}\n\n## [Today's Plan]{.blue}\n\n- Muddiest Point Review\n- Create New Feedback Surveys\n- Function Tutorials – Draft 2 Presentations\n\n## [Today's Learning Objectives]{.purple}\n\nAfter today's session you will be able to:\n\n. . .\n\n- Demonstrate integration of feedback\n- Refine a feedback survey\n- Explain R functions to an audience of your peers\n - Even more confidently!\n\n\n## [Muddiest Point Review]{.gold}\n\n- Recurring topics from most recent MPs:\n\n\\\n\n. . .\n\n- What other topic(s) would you like to review?\n\n## [Create a Google Form]{.pink} {.smaller}\n\n- Consult [Lab \\#5]{.blue} slides for a refresher on making Google Forms\n\n\\\n\n. . .\n\n- Make a new Google Form for peer feedback today\n - Remember to add me to the editing side!\n\n\\\n\n. . .\n\n- Your form should have (at least):\n - Question about whether people feel you addressed their feedback from [Draft 1]{.blue}\n - Any questions from first survey that you think are still valuable\n\n## [Feedback Reminder]{.orange}\n\nKeep the following pieces of advice in mind:\n\n\\\n\n. . .\n\n1. Be specific and reasonable!\n\n\\\n\n2. Pair critiques with positive comments\n\n\\\n\n3. Be constructively critical\n\n## [Temperature Check]{.purple}\n\n#### How are you Feeling?\n\n<p align=\"center\">\n<img src=\"comics/debugging.png\" alt=\"Comic-style graph depicting someone's emotional state as they debug code (from initial struggle and defeat to eventual triumph)\">\n</p>\n\n\n## [Get Ready]{.pink} {.smaller}\n\n- Find and open your R Markdown file\n - Knit it if you want\n\n\\\n\n. . .\n\n- Take a deep breath and relax!\n - [You got this]{.purple}!\n\n\\\n\n. . .\n\n- Let me know when you're ready\n\n## [Revised Function Tutorials]{.orange} {.smaller}\n\n- Something to keep in mind:\n - There is an <u>optional</u> 3^rd^ draft! \n - If you submit draft 3 and do better than draft 2, [it will replace your score]{.purple}\n - So take feedback seriously just in case you're unhappy with your draft 2 points!\n\n\\\n\n. . . \n\n- Anyone want to volunteer to go first?\n - I'll pick order randomly if there are no volunteers\n\n## [Temperature Check]{.purple}\n\n#### How are you Feeling?\n\n<p align=\"center\">\n<img src=\"comics/debugging.png\" alt=\"Comic-style graph depicting someone's emotional state as they debug code (from initial struggle and defeat to eventual triumph)\">\n</p>\n\n## [Upcoming Due Dates]{.blue} {.smaller}\n\n::::{.columns}\n:::{.column width=\"50%\"}\n\n### Due before lecture\n\n#### (By midnight)\n\n- Homework \\#7\n\n:::\n:::{.column width=\"50%\"}\n\n### Due before lab\n\n#### (By midnight)\n\n- Muddiest Point \\#8\n- Homework \\#8\n - Note reduced time to complete for this one!\n- GitHub Presence evaluation\n- _Optional_ 3^rd^ draft of Function Tutorials\n\n:::\n::::\n",
"supporting": [],
"filters": [
"rmarkdown/pagebreak.lua"
Expand Down
4 changes: 2 additions & 2 deletions _freeze/materials/slides_8a/execute-results/html.json

Large diffs are not rendered by default.

45 changes: 27 additions & 18 deletions materials/slides_6b.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,14 @@ fish_graph

\

. . .

- Elements can be modified as desired inside of `theme` function

\

. . .

- Each type of element has a different 'helper function' needed to modify that element
- Change text = use `element_text`
- Change line = use `element_line`
Expand All @@ -118,6 +122,8 @@ fish_graph

\

. . .

- Here's an example of the proper syntax
```{.r}
# Make a simple scatterplot
Expand All @@ -137,7 +143,7 @@ ggplot(data = my_df, mapping = aes(x = x_var, y = y_var)) +

## [Gridline Theme Components]{.orange} {.smaller}

- You'll learn theme element names as you work more with `ggplot2`
- You'll learn `theme` argument names as you work more with `ggplot2`

\

Expand Down Expand Up @@ -179,10 +185,14 @@ ggplot(data = my_df, mapping = aes(x = x_var, y = y_var)) +

\

. . .

- What does this do to your graph?

\

. . .

- What happens if you add these two lines as well (**inside** of the `theme` parentheses!)?
- `panel.background = element_blank()`
- `axis.line = element_line(color = "black"))`
Expand Down Expand Up @@ -226,7 +236,7 @@ fish_graph +

. . .

- Axis "[title]{.purple}" vs. axis "[text]{.gold}"
- Axis "[title]{.purple}" vs. axis "[text]{.purple}"
- `axis.title` = axis label text (given to `labs` function)
- `axis.text` = text on axis tick marks

Expand All @@ -238,15 +248,9 @@ fish_graph +

. . .

- Want to modify just X or Y? Add that to the element name!
- Want to modify just X or Y? Add that to the argument name!
- E.g., `theme(axis.text.x = element_text(...))`

\

. . .

Increase font size with: `element_text(size = 14)`

## [Change Text Size]{.pink} {.smaller}

![](images/hex-ggplot2.png){.absolute top=0 left=1100 width="12%" fig-alt="hex logo for ggplot2 R package"}
Expand Down Expand Up @@ -373,7 +377,7 @@ fish_graph +
\

- Two methods (for ggplots):
1. `ggplot2::facet_...`
1. `ggplot2::facet_grid()`
2. `cowplot::plot_grid()`

:::
Expand All @@ -390,11 +394,15 @@ fish_graph +

\

- Facets work just like geometries
. . .

- Facets work similarly to geometries
- You get separate plots for each level of the facet variable

\

. . .

- Facets must _all_ be the same plot type and _have identical axes_
- Sometimes not an issue but good to keep in mind!

Expand Down Expand Up @@ -482,7 +490,7 @@ ggplot(data = fish_df, aes(x = diameter_cm, y = depth_cm, color = species)) +
## [Plot Grids]{.orange} {.smaller}

- Facets work great when all panels are the same
- What about when you have several types of graph?
- What about when you want <u>different graphs in each panel</u>?

\

Expand Down Expand Up @@ -574,7 +582,7 @@ fish1 <- ggplot(data = fish_df, aes(x = diameter_cm, y = depth_cm, color = speci
theme(legend.position = "none")
# Make second desired graph
fish2 <- ggplot(data = fish_df, aes(x = species, y = flow_cfs, color = species)) +
fish2 <- ggplot(data = fish_df, aes(x = species, y = flow_cfs, fill = species)) +
geom_boxplot() +
labs(x = "Species", y = "Flow (cubic feet / second)") +
theme_bw() +
Expand Down Expand Up @@ -611,7 +619,7 @@ cowplot::plot_grid(fish1, fish2, labels = "AUTO", ncol = 2, nrow = 1)
## [GitHub Presence Assignment]{.orange} {.smaller}

- This assignment will seriously help in interviews / job apps!
- Shows how good of a data scientist you are
- Demonstrates your data science skills

\

Expand All @@ -632,21 +640,22 @@ cowplot::plot_grid(fish1, fish2, labels = "AUTO", ncol = 2, nrow = 1)
::::{.columns}
:::{.column width="50%"}

### Due before lecture
### Due before lab

#### (By midnight)

- Homework \#6
- Muddiest Point \#7

:::
:::{.column width="50%"}

### Due before lab
### Due before lecture

#### (By midnight)

- Muddiest Point \#7
- Submit [Draft 2]{.pink} of Function Tutorials
- Homework \#7
- Submit [Draft 2]{.blue} of Function Tutorials
- Double check rubric to see that you're not leaving any points on the table!
- Remember to also <u>submit the Revision Response</u>

Expand Down
98 changes: 49 additions & 49 deletions materials/slides_7a.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ format:

## [Today's Plan]{.blue}

- Choose [Lab \#8]{.blue} "Bonus Content"
- Code Iteration with Loops
- Conditionals in Loops
- In-Class Free Work
Expand All @@ -43,22 +42,6 @@ After today's session you will be able to:
- Apply loops to small arithmetic problems
- Create a loop with a conditional

## [Bonus Content]{.gold} {.smaller}

- [Lab \#8]{.blue} topic is your choice!

\

- Some options include:
- Biodiversity and ecological communities
- Pairwise comparisons (i.e., what to do after ANOVA says 'at least one group differs')
- Heatmaps

\

- What 1-2 topic(s) seem interesting to you?
- Feel free to propose topics that aren't listed!

## [Repeated Operations]{.orange} {.smaller}

- Often we want to repeat a given operation multiple times
Expand All @@ -82,7 +65,7 @@ After today's session you will be able to:

- Iteration process:
1. Define the operation that you want to repeat
2. Define what the values to be passed through that operation
2. Define the values to be passed through that operation
3. Press "go" and sit back while the code does the work!

\
Expand All @@ -98,7 +81,7 @@ After today's session you will be able to:

. . .

- This method is named "for loop"
- This method is called a "[for loop]{.purple}"

## [Loop Syntax]{.orange} {.smaller}

Expand Down Expand Up @@ -157,24 +140,31 @@ for(k in 1:5){

\

- Write a for loop that takes the square root of each number
- Function is `sqrt`
- Write a for loop that:
- 1. Takes the square root of each number (see `?sqrt`)
- 2. Prints that result (use `print` function)

- The loop should print the result for each square root in the Console
- Function is `print`
## [Loop Practice (Answer)]{.pink}

\
- Demonstrating on only a few numbers

. . .
```{r practice-answer-1}
#| echo: true
- Answer:
```{.r}
for(j in 5:25){
j_root <- sqrt(j)
print(j_root)
}
# Define loop
for(j in 5:8){
# Take square root
j_root <- sqrt(x = j)
# Print that result
print(x = j_root)
} # Close loop
```



## [More Loop Practice]{.pink} {.smaller}

- Write a second loop that:
Expand Down Expand Up @@ -281,6 +271,8 @@ for(k in 1:5){

\

. . .

- For the loop with `j` as the index:
- Make the `print` step tell you the starting number and its square root

Expand All @@ -296,7 +288,7 @@ for(j in 5:25){
}
```

## [More Message Pratice]{.pink} {.smaller}
## [More Message Practice]{.pink} {.smaller}

- For the loop with `i` as the index:
- Write a message that says each number and what it times 32 is equal to
Expand Down Expand Up @@ -324,29 +316,33 @@ for(i in 5:25){

- Syntax is similar to logical statements for subsetting
- Recall our earlier conversations about conditional operators:
- `==`, `&`, `!=`, `>`, etc.
- `==`, `&`, `>`, etc.

\

. . .

- Two main conditional functions: `if` & `else`

## [Conditional Syntax]{.orange} {.smaller}
## [Conditional Example]{.orange}

```{r demo-conditional}
#| echo: true
```{.r}
# Do something if a condition is met
if(2 == 2){
print("Math is mathing!")
# If that condition is not met...
} else { print("Math is--somehow--not mathing...") }
```
} else {
print("Math is--somehow--not mathing...")
\
}
```

. . .
## [Conditional Syntax]{.orange} {.smaller}

- `if` wants:
- Condition to check in parentheses `(...)`
Expand All @@ -363,7 +359,7 @@ if(2 == 2){
## [Multiple `if`s]{.orange} {.smaller}

- The example in the previous slide is just for one `if`
- Essentially 'either [this]{.purple} or [that]{.orange}'
- Essentially '[either this or that]{.purple}'

\

Expand All @@ -390,6 +386,8 @@ else if(x > 0){

\

. . .

- For example:
```{r ex-loop-3}
#| echo: true
Expand Down Expand Up @@ -443,8 +441,8 @@ for(value in my_vec){

## [In-Class Free Work]{.gold} {.smaller}

- Draft 2 of Function Tutorials is due tomorrow!
- Presentations during [Lab \#7]{.blue} (this week)!
- Draft 2 of Function Tutorials is due next week!
- Presentations during [Lecture \#8]{.blue}
- Requires 'revision response' where you discuss what changes you made due to feedback

\
Expand All @@ -466,23 +464,25 @@ for(value in my_vec){
::::{.columns}
:::{.column width="50%"}

### Due before lab
### Due before lecture

#### (By midnight)

- Muddiest Point \#7
- Submit [Draft 2]{.pink} of Function Tutorials
- Remember to include <u>_both_</u> the revised .Rmd _and_ your "revision response"
- Check the rubric for more details
- Homework \#7
- Submit [Draft 2]{.blue} of Function Tutorials
- Double check rubric to see that you're not leaving any points on the table!
- Remember to also <u>submit the Revision Response</u>

:::
:::{.column width="50%"}

### Due before lecture
### Due before lab

#### (By midnight)

- Homework \#7
- Homework \#8
- Muddiest Point \#8
- GitHub Presence

:::
::::
Loading

0 comments on commit ea712a8

Please sign in to comment.