Remove references to iris

This commit is contained in:
Mine Çetinkaya-Rundel 2021-02-21 17:12:13 +00:00
parent 32c625c6ef
commit 852f6b98a0
2 changed files with 11 additions and 11 deletions

View File

@ -102,7 +102,7 @@ Then we'll move on some variations of the for loop that help you solve other pro
1. Compute the mean of every column in `mtcars`.
2. Determine the type of each column in `nycflights13::flights`.
3. Compute the number of unique values in each column of `iris`.
3. Compute the number of unique values in each column of `palmerpenguins::penguins`.
4. Generate 10 random normals from distributions with means of -10, 0, 10, and 100.
Think about the output, sequence, and body **before** you start writing the loop.
@ -346,14 +346,14 @@ However, it is good to know they exist so that you're prepared for problems wher
What if the names are not unique?
3. Write a function that prints the mean of each numeric column in a data frame, along with its name.
For example, `show_mean(iris)` would print:
For example, `show_mean(mpg)` would print:
```{r, eval = FALSE}
show_mean(iris)
#> Sepal.Length: 5.84
#> Sepal.Width: 3.06
#> Petal.Length: 3.76
#> Petal.Width: 1.20
show_mean(mpg)
#> displ: 3.47
#> year: 2004
#> cyl: 5.89
#> cty: 16.86
```
(Extra challenge: what function did I use to make sure that the numbers lined up nicely, even though the variable names had different lengths?)
@ -636,7 +636,7 @@ I focus on purrr functions here because they have more consistent names and argu
1. Compute the mean of every column in `mtcars`.
2. Determine the type of each column in `nycflights13::flights`.
3. Compute the number of unique values in each column of `iris`.
3. Compute the number of unique values in each column of `palmerpenguins::penguins`.
4. Generate 10 random normals from distributions with means of -10, 0, 10, and 100.
2. How can you create a single vector that for each column in a data frame indicates whether or not it's a factor?
@ -909,11 +909,11 @@ A number of functions work with **predicate** functions that return either a sin
`keep()` and `discard()` keep elements of the input where the predicate is `TRUE` or `FALSE` respectively:
```{r}
iris %>%
gss_cat %>%
keep(is.factor) %>%
str()
iris %>%
gss_cat %>%
discard(is.factor) %>%
str()
```

View File

@ -26,7 +26,7 @@ Most other R packages use regular data frames, so you might want to coerce a dat
You can do that with `as_tibble()`:
```{r}
as_tibble(iris)
as_tibble(mtcars)
```
You can create a new tibble from individual vectors with `tibble()`.