load(url("https://github.com/vsass/CSSS508/raw/main/Lectures/Lecture7/data/restaurants.Rdata"))
Homework 7
Key
Click link above for example solutions to this assignment.
Instructions
Answer each of the following questions. Be sure to display all your code in the rendered version (use echo: true
throughout1).
Use the following code to read in the King County restaurant data for this assignment:
Exercises
Question 1:
What is the shortest restaurant name? What is the longest restaurant name?
Question 2:
Read the documentation for separate_longer_delim()
. Use this function to figure out what 10 “words”2 are most frequently used for the restaurant names in this data set.
Question 3:
Which zip code has the highest (meaning worst) mean Grade
?3 For that worst-rated zip code, how has its average rating changed by year?4
Question 4 (OPTIONAL):
Separate the variable Phone
into three variables that only contain numerical digits: area_code
, first_3
, and last_4
.
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 ---
Anything that is separated by spaces counts as a word for this problem.↩︎
Note: To accurately reflect the true average you’ll want to weight this by restaurant: i.e. get the average grade by restaurant first, then get the average of those averages by zip code.↩︎
There are a few ways to do this. Use the method that makes most sense to you!↩︎