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:

load(url("https://github.com/vsass/CSSS508/raw/main/Lectures/Lecture7/data/restaurants.Rdata"))

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

  1. 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
    ---
    ↩︎
  2. Anything that is separated by spaces counts as a word for this problem.↩︎

  3. 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.↩︎

  4. There are a few ways to do this. Use the method that makes most sense to you!↩︎