# | Homework Due | Peer Review Due |
---|---|---|
1 | 2 April | 7 April |
2 | 9 April | 14 April |
3 | 16 April | 21 April |
4 | 23 April | 28 April |
5 | 30 April | 5 May |
6 | 7 May | 12 May |
7 | 14 May | 19 May |
8 | 21 May | 26 May |
9 | 28 May | 2 June |
Homework 8
Key
Click link above for answers to homework 8.
Instructions
Answer each of the following questions. Be sure to display all your code in the rendered version (use echo: true
throughout1).
Exercises
Question 1:
Given a vector of birthdates2, write a function to compute the age in years3.
Question 2:
For each of the following functions list all arguments that use tidy evaluation and describe whether they use data-masking or tidy-selection: distinct()
, count()
, group_by()
4, rename_with()
, slice_min()
, slice_sample()
.
Question 3:
Build up a rich plotting function by incrementally implementing each of the steps below:
- Draw a scatterplot given
dataset
andx
andy
variables. - Add a line of best fit (i.e. a linear model with no standard errors)5.
- Add a title that includes the names of the variables used.
Test your function with the built-in cars
, swiss
, and iris
datasets.
Due Dates
Footnotes
You can make this a global option for your whole document by putting it directly in the YAML of your qmd:
--- title: "My Document" execute: echo: true ---
Assume
mdy
format for this vector.↩︎Depending upon how you want to solve this problem, the lubridate functions
today()
andtime_length()
could be useful here :)↩︎Note:
group_by()
doesn’t list what type of tidy evaluation it uses for its...
argument but you can find the answer in the introduction to this article.↩︎geom_smooth()
has amethod
andse
argument that will be necessary to specify here.↩︎