Starting from:
$35

$29

Lab 14 Solution


Submit your HTML markdown document by the beginning of class.


Exercises

    1. Cal Poly isn’t the only Best-in-the-West! Numerous people swear by In-N-Out and the good, old-fashioned, high-quality burgers, fries, and shakes they deliver. It’s widely thought that In-N-Out establishments only exist in California, but let’s do a little investigating and create some fun visualizations along the way!

        a) The locations and opening dates of all current In-N-Out establishments can be found at http: //www.lasvegas360.com/3428/in-n-out-burger-locations-and-store-numbers/ Import (scrape) this data into R.

        b) Organize the data into a nice matrix, data frame, or tibble. I believe there should be at most 5 columns: observation number, city, address, state, open date. Note that the first 45 rows in the table on the webpage have images in them and so end up with some extra fields when imported, which you’ll need to eliminate first.

        c) Fix the State and Date Opened for store number 5 in Pasadena.

        d) Use the state.name and state.abb variables pre-loaded in R to add full state names to your existing dataset.

        e) Are In-N-Out establishments only in California? What’s the distribution of the state variable?

        f) What’s the eastern-most In-N-Out? What state is it in?

        g) Create a map of the states that contain In-N-Out restaurants, colored by the number of locations in each of those states. It should look something like the map below. Consider using RColorBrewer to generate the colors.

























1



In−N−Out Locations in U.S.

(Darker = More Locations)



























    2. Does America really run on Dunkin?!? Perhaps the two most popular establishments for people to get “fast" coffee in America are Dunkin Donuts and Starbucks. Let’s investigate and compare these two chains a bit.

    a) Scrape the state data on the number of Starbucks and Dunkin’ Donuts locations in the U.S. from the following two sites:

    • https://www.menuism.com/restaurant-locations/dunkin-donuts-181624/us

    • https://www.menuism.com/restaurant-locations/starbucks-coffee-39564/us

    b) Organize the data into a nice matrix, data frame, or tibble. Extract the location counts for each state from the character strings you scraped.

    c) Extract the state names as well so that you’re left with just a data frame or tibble with information for each state on the number of Starbucks and Dunkin’ Donuts locations.

    d) Plot a map of the United States with states colored by which establishment is more prevalent (beware of the all the state subregions that get plotted with the maps package). Be sure to include appropriate labels, legend, and a title. Does America run on Dunkin? Explain.














2


























Dunkin Donuts vs. Starbucks


Dunkin Donuts
(colored by majority presence)










Starbucks





















































3

More products