Skip to content

Commit

Permalink
small tweaks to warm-up slides
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanhcullen committed Aug 9, 2024
1 parent 025f13a commit b5234c3
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 39 deletions.
39 changes: 28 additions & 11 deletions slides/warm-up.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class: your-turn
.pull-left[
```{r eval = FALSE}
seattle_pets |>
count(species, sort = TRUE)
count(species)
```

or...
Expand All @@ -229,7 +229,7 @@ seattle_pets |>

.pull-right[
```{r echo = FALSE, message = FALSE}
seattle_pets |> count(species, sort = TRUE)
seattle_pets |> count(species)
```
]

Expand All @@ -240,7 +240,7 @@ class: your-turn

**What is the most popular pet name in this data set?**

`r emo::ji("bulb")` Hint: Look up the help documentation for `slice_max()` from dplyr.
`r emo::ji("bulb")` Hint: Try using `slice_max()` from dplyr in your solution. Look up the help docs with `?slice_max`.

---

Expand All @@ -251,17 +251,24 @@ class: your-turn
```{r eval = FALSE}
seattle_pets |>
count(animal_name) |>
slice_max(order_by = n) |>
pull(animal_name)
slice_max(order_by = n)
```

or...

```{r eval=FALSE}
seattle_pets |>
count(animal_name, sort = TRUE) |>
head(1)
```


or...

```{r eval=FALSE}
seattle_pets |>
count(animal_name) |>
filter(n == max(n)) |>
pull(animal_name)
filter(n == max(n))
```

]
Expand All @@ -271,8 +278,7 @@ seattle_pets |>
```{r echo = FALSE, message = FALSE}
seattle_pets |>
count(animal_name) |>
slice_max(order_by = n) |>
pull(animal_name)
slice_max(order_by = n)
```

]
Expand Down Expand Up @@ -349,11 +355,22 @@ seattle_pets |>
filter(species == "Dog") |>
count(primary_breed) |>
slice_max(order_by = n, n = 10) |>
ggplot(aes(primary_breed, n)) +
ggplot(aes(x = primary_breed, y = n)) +
geom_col() +
coord_flip()
```

or ...

```{r}
seattle_pets |>
filter(species == "Dog") |>
count(primary_breed) |>
slice_max(order_by = n, n = 10) |>
ggplot(aes(x = n, y = primary_breed)) +
geom_col()
```

]

.pull-right[
Expand All @@ -362,7 +379,7 @@ seattle_pets |>
filter(species == "Dog") |>
count(primary_breed) |>
slice_max(order_by = n, n = 10) |>
ggplot(aes(primary_breed, n)) +
ggplot(aes(x = primary_breed, y = n)) +
geom_col() +
coord_flip()
```
Expand Down
81 changes: 53 additions & 28 deletions slides/warm-up.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@
```
## Rows: 43,683
## Columns: 7
## $ license_issue_date <chr> "December 18 2015", "June 14 2016", "August 04 2016…
## $ license_number <chr> "S107948", "S116503", "S119301", "962273", "S133113…
## $ animal_name <chr> "Zen", "Misty", "Lyra", "Veronica", "Spider", "Maxx…
## $ species <chr> "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "C
## $ primary_breed <chr> "Domestic Longhair", "Siberian", "Mix", "Domestic L
## $ secondary_breed <chr> "Mix", NA, NA, NA, NA, NA, "Mix", "Mix", "Mix", "Mi
## $ zip_code <dbl> 98117, 98117, 98121, 98107, 98115, 98125, 98103, 98
## $ license_issue_date <chr> "December 18 2015", "June 14 2016", "August 04 2016", "February 13 2019", "August 10 2019"
## $ license_number <chr> "S107948", "S116503", "S119301", "962273", "S133113", "8002549", "S112835", "S131986", "S1
## $ animal_name <chr> "Zen", "Misty", "Lyra", "Veronica", "Spider", "Maxx", "Diamond", "Nacho", "Pixel", "C.C.",
## $ species <chr> "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "Cat",
## $ primary_breed <chr> "Domestic Longhair", "Siberian", "Mix", "Domestic Longhair", "LaPerm", "American Shorthair
## $ secondary_breed <chr> "Mix", NA, NA, NA, NA, NA, "Mix", "Mix", "Mix", "Mix", "American Shorthair", "Mix", NA, NA
## $ zip_code <dbl> 98117, 98117, 98121, 98107, 98115, 98125, 98103, 98126, 98112, 98117, 98126, 98199, 98115,
```


Expand All @@ -151,13 +151,13 @@
```
## Rows: 43,683
## Columns: 7
## $ license_issue_date <chr> "December 18 2015", "June 14 2016", "August 04 2016…
## $ license_number <chr> "S107948", "S116503", "S119301", "962273", "S133113…
## $ animal_name <chr> "Zen", "Misty", "Lyra", "Veronica", "Spider", "Maxx…
## $ species <chr> "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "C
## $ primary_breed <chr> "Domestic Longhair", "Siberian", "Mix", "Domestic L
## $ secondary_breed <chr> "Mix", NA, NA, NA, NA, NA, "Mix", "Mix", "Mix", "Mi
## $ zip_code <dbl> 98117, 98117, 98121, 98107, 98115, 98125, 98103, 98
## $ license_issue_date <chr> "December 18 2015", "June 14 2016", "August 04 2016", "February 13 2019", "August 10 2019"
## $ license_number <chr> "S107948", "S116503", "S119301", "962273", "S133113", "8002549", "S112835", "S131986", "S1
## $ animal_name <chr> "Zen", "Misty", "Lyra", "Veronica", "Spider", "Maxx", "Diamond", "Nacho", "Pixel", "C.C.",
## $ species <chr> "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "Cat", "Cat",
## $ primary_breed <chr> "Domestic Longhair", "Siberian", "Mix", "Domestic Longhair", "LaPerm", "American Shorthair
## $ secondary_breed <chr> "Mix", NA, NA, NA, NA, NA, "Mix", "Mix", "Mix", "Mix", "American Shorthair", "Mix", NA, NA
## $ zip_code <dbl> 98117, 98117, 98121, 98107, 98115, 98125, 98103, 98126, 98112, 98117, 98126, 98199, 98115,
```

---
Expand All @@ -178,7 +178,7 @@

```r
seattle_pets |>
count(species, sort = TRUE)
count(species)
```

or...
Expand All @@ -198,8 +198,8 @@
## # A tibble: 4 × 2
## species n
## <chr> <int>
## 1 Dog 29729
## 2 Cat 13935
## 1 Cat 13935
## 2 Dog 29729
## 3 Goat 16
## 4 Pig 3
```
Expand All @@ -212,7 +212,7 @@

**What is the most popular pet name in this data set?**

💡 Hint: Look up the help documentation for `slice_max()` from dplyr.
💡 Hint: Try using `slice_max()` from dplyr in your solution. Look up the help docs with `?slice_max`.

---

Expand All @@ -224,18 +224,26 @@
```r
seattle_pets |>
count(animal_name) |>
slice_max(order_by = n) |>
pull(animal_name)
slice_max(order_by = n)
```

or...


```r
seattle_pets |>
count(animal_name, sort = TRUE) |>
head(1)
```


or...


```r
seattle_pets |>
count(animal_name) |>
filter(n == max(n)) |>
pull(animal_name)
filter(n == max(n))
```

]
Expand All @@ -244,7 +252,10 @@


```
## [1] "Luna"
## # A tibble: 1 × 2
## animal_name n
## <chr> <int>
## 1 Luna 410
```

]
Expand Down Expand Up @@ -310,7 +321,7 @@
]

.pull-right[
<img src="warm-up_files/figure-html/unnamed-chunk-14-1.png" width="80%" />
<img src="warm-up_files/figure-html/unnamed-chunk-15-1.png" width="80%" />

]

Expand All @@ -326,15 +337,29 @@
filter(species == "Dog") |>
count(primary_breed) |>
slice_max(order_by = n, n = 10) |>
ggplot(aes(primary_breed, n)) +
ggplot(aes(x = primary_breed, y = n)) +
geom_col() +
coord_flip()
```

or ...


```r
seattle_pets |>
filter(species == "Dog") |>
count(primary_breed) |>
slice_max(order_by = n, n = 10) |>
ggplot(aes(x = n, y = primary_breed)) +
geom_col()
```

<img src="warm-up_files/figure-html/unnamed-chunk-17-1.png" width="504" />

]

.pull-right[
<img src="warm-up_files/figure-html/unnamed-chunk-16-1.png" width="80%" />
<img src="warm-up_files/figure-html/unnamed-chunk-18-1.png" width="80%" />

]

Expand All @@ -354,7 +379,7 @@
]

.pull-right[
<img src="warm-up_files/figure-html/unnamed-chunk-17-1.png" width="90%" />
<img src="warm-up_files/figure-html/unnamed-chunk-19-1.png" width="90%" />

]

Expand All @@ -369,7 +394,7 @@

.pull-right[

<img src="warm-up_files/figure-html/unnamed-chunk-18-1.png" width="90%" />
<img src="warm-up_files/figure-html/unnamed-chunk-20-1.png" width="90%" />

]

Expand Down

0 comments on commit b5234c3

Please sign in to comment.