---
title: "My Document"
execute:
echo: true
---Homework 9
Key
Click link above for answers to homework 9.
Instructions
Answer each of the following questions using the iterative techniques covered in lecture. Be sure to display all your code in the rendered version (use echo: true throughout1).
1 You can make this a global option for your whole document by putting it directly in the YAML of your qmd:
Exercises
Question 1:
Compute the number of unique values in each column of palmerpenguins::penguins2.
2 You’ll need to download the palmerpenguins package in order to use penguins dataset.
Question 2:
Compute the mean of every column in mtcars.
Question 3:
Group diamonds by cut, clarity, and color then count the number of observations and compute the mean of each numeric column.
Question 4:
What happens if you use a list of functions in across(), but don’t name them? How is the output named?
Question 5:
- Explain what each step of the following pipeline does. If you haven’t seen the function before, look up its help page to learn the specifics of what it does.
diamonds |>
split(diamonds$cut) |>
map(\(df) lm(price ~ carat, data = df)) |>
map(summary) |>
map_dbl("r.squared")- 1
-
A function from base
Rthat does not use tidy evaluation and therefore requires base indexing with$
> Fair Good Very Good Premium Ideal
> 0.7383940 0.8509539 0.8581622 0.8556336 0.8670887
Due Dates
| # | Homework Due | Peer Review Due |
|---|---|---|
| 1 | 7 October | 12 October |
| 2 | 14 October | 19 October |
| 3 | 21 October | 26 October |
| 4 | 28 October | 2 November |
| 5 | 11 November | 16 November |
| 6 | 18 November | 23 November |
| 7 | 25 November | 30 November |
| 8 | 2 December | 7 December |
| 9 | 9 December | 14 December |