Skip to content

Commit

Permalink
Added all slide headings and fleshed out most of the slides dealing w…
Browse files Browse the repository at this point in the history
…ith discussion of the function tutorial assignment
  • Loading branch information
njlyon0 committed Feb 2, 2024
1 parent a0a65d5 commit c7e4e61
Show file tree
Hide file tree
Showing 2 changed files with 289 additions and 7 deletions.
4 changes: 2 additions & 2 deletions _freeze/materials/slides_3b/execute-results/html.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"hash": "61dbf9c61b8f9e971d72c735475e0ca5",
"hash": "d360334388d386effbe940a882ba3e38",
"result": {
"markdown": "---\ntitle: \"Intro to Data Science\"\nauthor: \"Lab 3 -- Data Wrangling (P2)\"\nengine: knitr\nformat: \n revealjs: \n slide-number: c\n\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- Y\n\n## [Today's Learning Objectives]{.purple}\n\nAfter today's session you will be able to:\n\n. . .\n\n- X\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\n## [Upcoming Due Dates]{.blue} {.smaller}\n\n::::{.columns}\n\n:::{.column width=\"50%\"}\n\n### Due before lecture\n\n#### (By midnight)\n\n- x\n\n:::\n\n:::{.column width=\"50%\"}\n\n### Due before lab\n\n#### (By midnight)\n\n- X\n\n:::\n\n::::\n\n",
"markdown": "---\ntitle: \"Intro to Data Science\"\nauthor: \"Lab 3 -- Data Wrangling (P2)\"\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- Intro to the Pipe\n- Groupwise Summarization with `dplyr`\n- Reshaping Data with `tidyr`\n- Discuss Function Tutorial Assignment\n\n## [Today's Learning Objectives]{.purple}\n\nAfter today's session you will be able to:\n\n. . .\n\n- Use the pipe operator in your code\n- Perform group summarization with `dplyr` functions\n- Reshape data from long to wide format\n - And vice versa\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## [Pipe Operator (`%>%`)]{.orange}\n\n- Allows chaining together multiple operations\n\n\\\n\n- Product of each function passed to next function\n```{.r}\nnew_data <- old_data %>%\n\t\t\tfunction() %>%\n\t\t\tanother_fxn() %>%\n\t\t\tetc()\n```\n\n\\\n\n- Same workflow requires fewer objects\n\n## [Pipe Operator Example]{.orange} {.smaller}\n\n### Without Pipe\n\n```{.r}\n# Load data\ndf_v1 <- read.csv(\"butterfly.csv\")\n\n# Subset to only one treatment\ndf_v2 <- filter(df_v1, treatment == \"cows\")\n\n# Add together caterpillars and adult butterflies\ndf_v3 <- mutate(df_v2, monarch.tot = monarch.bfly + monarch.larva)\n\n# Keep only the total monarch column\ndf_v4 <- select(df_v3, monarch)\n```\n\n## [Pipe Operator Example]{.orange} {.smaller}\n\n### Without Pipe\n\n```{.r}\n# Load data\ndf_v1 <- read.csv(\"butterfly.csv\")\n\n# Subset to only one treatment\ndf_v2 <- filter(df_v1, treatment == \"cows\")\n\n# Add together caterpillars and adult butterflies\ndf_v3 <- mutate(df_v2, monarch.tot = monarch.bfly + monarch.larva)\n\n# Keep only the total monarch column\ndf_v4 <- select(df_v3, monarch)\n```\n\n### With Pipe\n\n```{.r}\n# Load data\ndf_v1 <- read.csv(\"butterfly.csv\")\n\n# Do all needed wrangling\ndf_done <- df_v1 %>%\n # Subset to only one treatment\n filter(treatment == \"cows\") %>%\n # Add together caterpillars and adult butterflies\n mutate(monarch.tot = monarch.bfly + monarch.larva) %>% \n # Keep only the total monarch column\n select(df_v3, monarch)\n```\n\n## [Why Named \"Pipe\"?]{.orange}\n\n\n\n## [Practice: Pipe]{.pink}\n\n\n\n## [Groupwise Summarization]{.orange}\n\n\n## [Summarization Syntax]{.orange}\n\n\n\n## [Summarization Warning]{.orange}\n\n\n\n## [Relevant Helper Functions]{.orange}\n\n\n\n## [Practice: Summarizing]{.}\n\n\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## [Data \"Shape\"]{.orange}\n\n\n\n## [Reshaping Longer]{.orange}\n\n\n\n## [Reshaping Longer Continued]{.orange}\n\n\n\n## [Reshaping Longer Visual]{.orange}\n\n\n## [Practice: `pivot_longer`]{.}\n\n\n## [Reshaping Wider]{.orange}\n\n\n\n## [Reshaping Wider Continued]{.orange}\n\n\n\n## [Reshaping Wider Visual]{.orange}\n\n\n## [Practice: `pivot_wider`]{.}\n\n\n\n\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## [Function Tutorial: Learning Objectives]{.orange}\n\nAfter completing this assignment you will be able to:\n\n. . .\n\n- Explain the proper syntax and use of R functions\n- Communicate effectively to an audience of interested non-specialists\n- Apply feedback on an assignment to a successful revision\n- Reflect on the process of revising a presentation based on constructively critical feedback\n\n## [Function Tutorial: FAQ]{.orange} {.smaller}\n\n- Tutorial should be an R Markdown with plain text and code chunks\n - Write tutorials for your classmates for three functions from packages on CRAN\n\n\\\n\n. . .\n\n- You’ll present your tutorials for 5-10 minutes in [Lab \\#5]{.blue}\n - Get peer feedback then & implement changes before submitting draft 2\n\n\\\n\n. . . \n\n- Submit & present revised tutorials during [Lab \\#7]{.pink}\n\n## [Function Tutorial: Points]{.orange} {.smaller}\n\n- **Draft 1 = 30 pts (12% course grade)**\n - Overall report – 6 pts\n - Function tutorial (x3) – 8 pts each\n\n. . . \n\n- **Draft 2 = 40 pts (16% of grade)**\n - Overall report – 6 pts\n - Function tutorial (x3) – 8 pts each\n - Revision response – 3 pts\n - Edited from draft 1 from peer feedback – 7 pts\n\n. . . \n\n- [**_Optional_**]{.gold} Draft 3 = 40 pts\n - If submitted, score replaces draft 2\n - <u>Score can only improve</u> (no way draft 3 reduces total points earned)\n\n## [Picking Functions]{.orange} {.smaller}\n\n- Everyone must pick three _different_ functions\n - This way no two people present tutorials on the same function\n\n- Unfortunately, means if someone picks before you they \"claim\" that function\n\n. . .\n\n\\\n\n- My plan to do this equitably is as follows:\n 1. Randomize student order and each person picks one function\n 2. Second function picked in reverse of that order (I.e., if you were last to pick in round 1, you're first in round 2)\n 3. Re-randomize student order for third function\n\n\\\n\n- Sound fair? If not, what’s a good alternative?\n\n## [Nick's _Recommended_ Packages]{.orange}\n\n\n## [Forbidden Packages (Sorry!)]{.orange}\n\n\n\n## [Assignment Q & A]{.gold}\n\n- What questions do you have about this assignment?\n - No \"dumb\" questions so ask away!\n\n\\\n\n. . .\n\n- Feeling good about next steps?\n\n\n## [Exploring CRAN Packages]{.orange} {.smaller}\n\n- Visit [cran.r-project.org](https://cran.r-project.org/)\n\n\\\n\n- Click \"Packages\" on the left sidebar\n - Approx. 2/3 down sidebar items\n\n\\\n\n- Click \"Table of available packages, sorted by name\"\n\n\\\n\n- Scroll through and look for one with a cool name / title!\n\n## [Practice: Exploring CRAN]{.pink}\n\n- Explore available packages / functions\n\n\\\n\n- Select 7-10 functions so you have alternates (if needed)\n\n\\\n\n- We will pick functions during next lecture ([Lecture \\#4]{.blue})\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\n:::{.column width=\"50%\"}\n\n### Due before lecture\n\n#### (By midnight)\n\n- Homework \\#3\n- Pick 7-10 possible functions for Function Tutorial assignment\n - Remember, they **_must_** be from CRAN packages!\n\n\n:::\n\n:::{.column width=\"50%\"}\n\n### Due before lab\n\n#### (By midnight)\n\n- Muddiest Point \\#4\n\n:::\n\n::::\n\n",
"supporting": [],
"filters": [
"rmarkdown/pagebreak.lua"
Expand Down
292 changes: 287 additions & 5 deletions materials/slides_3b.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ engine: knitr
format:
revealjs:
slide-number: c

scrollable: false
code-overflow: wrap
code-line-numbers: false
Expand All @@ -29,15 +28,172 @@ format:

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

- Y
- Muddiest Point Review
- Intro to the Pipe
- Groupwise Summarization with `dplyr`
- Reshaping Data with `tidyr`
- Discuss Function Tutorial Assignment

## [Today's Learning Objectives]{.purple}

After today's session you will be able to:

. . .

- X
- Use the pipe operator in your code
- Perform group summarization with `dplyr` functions
- Reshape data from long to wide format
- And vice versa

## [Muddiest Point Review]{.gold}

- Recurring topics from most recent MPs:

\

. . .

- What other topic(s) would you like to review?

## [Pipe Operator (`%>%`)]{.orange}

- Allows chaining together multiple operations

\

- Product of each function passed to next function
```{.r}
new_data <- old_data %>%
function() %>%
another_fxn() %>%
etc()
```

\

- Same workflow requires fewer objects

## [Pipe Operator Example]{.orange} {.smaller}

### Without Pipe

```{.r}
# Load data
df_v1 <- read.csv("butterfly.csv")
# Subset to only one treatment
df_v2 <- filter(df_v1, treatment == "cows")
# Add together caterpillars and adult butterflies
df_v3 <- mutate(df_v2, monarch.tot = monarch.bfly + monarch.larva)
# Keep only the total monarch column
df_v4 <- select(df_v3, monarch)
```

## [Pipe Operator Example]{.orange} {.smaller}

### Without Pipe

```{.r}
# Load data
df_v1 <- read.csv("butterfly.csv")
# Subset to only one treatment
df_v2 <- filter(df_v1, treatment == "cows")
# Add together caterpillars and adult butterflies
df_v3 <- mutate(df_v2, monarch.tot = monarch.bfly + monarch.larva)
# Keep only the total monarch column
df_v4 <- select(df_v3, monarch)
```

### With Pipe

```{.r}
# Load data
df_v1 <- read.csv("butterfly.csv")
# Do all needed wrangling
df_done <- df_v1 %>%
# Subset to only one treatment
filter(treatment == "cows") %>%
# Add together caterpillars and adult butterflies
mutate(monarch.tot = monarch.bfly + monarch.larva) %>%
# Keep only the total monarch column
select(df_v3, monarch)
```

## [Why Named "Pipe"?]{.orange}



## [Practice: Pipe]{.pink}



## [Groupwise Summarization]{.orange}


## [Summarization Syntax]{.orange}



## [Summarization Warning]{.orange}



## [Relevant Helper Functions]{.orange}



## [Practice: Summarizing]{.}



## [Temperature Check]{.purple}

#### How are you Feeling?

<p align="center">
<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)">
</p>

## [Data "Shape"]{.orange}



## [Reshaping Longer]{.orange}



## [Reshaping Longer Continued]{.orange}



## [Reshaping Longer Visual]{.orange}


## [Practice: `pivot_longer`]{.}


## [Reshaping Wider]{.orange}



## [Reshaping Wider Continued]{.orange}



## [Reshaping Wider Visual]{.orange}


## [Practice: `pivot_wider`]{.}





## [Temperature Check]{.purple}

Expand All @@ -47,7 +203,130 @@ After today's session you will be able to:
<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)">
</p>

## [Function Tutorial: Learning Objectives]{.orange}

After completing this assignment you will be able to:

. . .

- Explain the proper syntax and use of R functions
- Communicate effectively to an audience of interested non-specialists
- Apply feedback on an assignment to a successful revision
- Reflect on the process of revising a presentation based on constructively critical feedback

## [Function Tutorial: FAQ]{.orange} {.smaller}

- Tutorial should be an R Markdown with plain text and code chunks
- Write tutorials for your classmates for three functions from packages on CRAN

\

. . .

- You’ll present your tutorials for 5-10 minutes in [Lab \#5]{.blue}
- Get peer feedback then & implement changes before submitting draft 2

\

. . .

- Submit & present revised tutorials during [Lab \#7]{.pink}

## [Function Tutorial: Points]{.orange} {.smaller}

- **Draft 1 = 30 pts (12% course grade)**
- Overall report – 6 pts
- Function tutorial (x3) – 8 pts each

. . .

- **Draft 2 = 40 pts (16% of grade)**
- Overall report – 6 pts
- Function tutorial (x3) – 8 pts each
- Revision response – 3 pts
- Edited from draft 1 from peer feedback – 7 pts

. . .

- [**_Optional_**]{.gold} Draft 3 = 40 pts
- If submitted, score replaces draft 2
- <u>Score can only improve</u> (no way draft 3 reduces total points earned)

## [Picking Functions]{.orange} {.smaller}

- Everyone must pick three _different_ functions
- This way no two people present tutorials on the same function

- Unfortunately, means if someone picks before you they "claim" that function

. . .

\

- My plan to do this equitably is as follows:
1. Randomize student order and each person picks one function
2. Second function picked in reverse of that order (I.e., if you were last to pick in round 1, you're first in round 2)
3. Re-randomize student order for third function

\

- Sound fair? If not, what’s a good alternative?

## [Nick's _Recommended_ Packages]{.orange}


## [Forbidden Packages (Sorry!)]{.orange}



## [Assignment Q & A]{.gold}

- What questions do you have about this assignment?
- No "dumb" questions so ask away!

\

. . .

- Feeling good about next steps?


## [Exploring CRAN Packages]{.orange} {.smaller}

- Visit [cran.r-project.org](https://cran.r-project.org/)

\

- Click "Packages" on the left sidebar
- Approx. 2/3 down sidebar items

\

- Click "Table of available packages, sorted by name"

\

- Scroll through and look for one with a cool name / title!

## [Practice: Exploring CRAN]{.pink}

- Explore available packages / functions

\

- Select 7-10 functions so you have alternates (if needed)

\

- We will pick functions during next lecture ([Lecture \#4]{.blue})

## [Temperature Check]{.purple}

#### How are you Feeling?

<p align="center">
<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)">
</p>

## [Upcoming Due Dates]{.blue} {.smaller}

Expand All @@ -59,7 +338,10 @@ After today's session you will be able to:

#### (By midnight)

- x
- Homework \#3
- Pick 7-10 possible functions for Function Tutorial assignment
- Remember, they **_must_** be from CRAN packages!


:::

Expand All @@ -69,7 +351,7 @@ After today's session you will be able to:

#### (By midnight)

- X
- Muddiest Point \#4

:::

Expand Down

0 comments on commit c7e4e61

Please sign in to comment.