Presidential Chicken

Wordcloud of top menu items at MSU dining halls from 10/5/18 - 10/15/18

I remember back in undergrad when I visited my friends at Michigan State and they took me to the residential dining hall since they had a meal plan. The cafeteria had typical dorm food like salad bar, burgers, hot dogs, fries etc. Fortunately, the dining halls have improved drastically since then and now the undergraduate students have it great with so many options available to them.

Eat at State

A common theme in the lab is to ask one another what do you have for lunch today? Sometimes we don’t bring anything and our options are to go to the international center food court, the restaurants on Grand River or the residential dining halls. MSU employees have a great option to buy admission into the dining hall at a discounted rate so I always tag along with them so they can swipe me in. We typically preview the menus at eatatstate.msu.edu and will choose to go to the dining hall one with the best menu. One of my favorite dishes from the cafeteria is Presidential Chicken which is a chicken dish with an alfredo like sauce with vegetables and is wrapped up in puff pastry envelope. It tastes great and is exponentially better than the food I’ve had at weddings. We haven’t seen the dish on the menu in well over a year so I decided to see if I could scrape the menus and make a quick shiny dashboard to figure out the next time they would serve it.

library(rvest)
library(knitr)
library(kableExtra)
library(tidyverse)
library(lubridate)

Generate urls

The key to generating a list of URLs for scraping is to identify the patterns of interest and stick them together using the paste() function. Here I used the main eatatstate domain and simply created an object for each dining hall. Then I can use the paste function to link them together so then I have URLs for each dining hall. Then I generated a sequence of dates and appended it to the dining hall URLs.

domain <- "https://eatatstate.msu.edu/menu/"
shaw <- "The%20Vista%20at%20Shaw/all/"
sny_phy <- "The%20Gallery%20at%20Snyder%20Phillips/all/"
landon <- "Heritage%20Commons%20at%20Landon/all/"

dining_halls <- c(shaw, sny_phy, landon)

# List of dates
future_date <- ymd(today()) + days(10)
dates <- seq(ymd(today()), future_date, by = 'day')

# Number of dining halls
dining_hall_no <- length(dining_halls) %>%
  unlist()

# Create lunch urls
day_url <- dining_halls %>% 
  map(~paste(domain, .x, dates, sep = "")) %>%
  unlist()

dining_halls
## [1] "The%20Vista%20at%20Shaw/all/"               
## [2] "The%20Gallery%20at%20Snyder%20Phillips/all/"
## [3] "Heritage%20Commons%20at%20Landon/all/"
dates
##  [1] "2019-12-19" "2019-12-20" "2019-12-21" "2019-12-22" "2019-12-23"
##  [6] "2019-12-24" "2019-12-25" "2019-12-26" "2019-12-27" "2019-12-28"
## [11] "2019-12-29"
day_url %>% 
  head()
## [1] "https://eatatstate.msu.edu/menu/The%20Vista%20at%20Shaw/all/2019-12-19"
## [2] "https://eatatstate.msu.edu/menu/The%20Vista%20at%20Shaw/all/2019-12-20"
## [3] "https://eatatstate.msu.edu/menu/The%20Vista%20at%20Shaw/all/2019-12-21"
## [4] "https://eatatstate.msu.edu/menu/The%20Vista%20at%20Shaw/all/2019-12-22"
## [5] "https://eatatstate.msu.edu/menu/The%20Vista%20at%20Shaw/all/2019-12-23"
## [6] "https://eatatstate.msu.edu/menu/The%20Vista%20at%20Shaw/all/2019-12-24"

Next we will generate the URLs for lunch and dinner and combine them all.

# Create dinner urls
dinner <- "?field_mealtime_target_id=191"

night_url <- dining_halls %>% 
  map(~paste(domain, .x, dates, dinner, sep = "")) %>%
  unlist()

# Combine url list
all_url <- c(day_url, night_url)

all_url %>% 
  head()
## [1] "https://eatatstate.msu.edu/menu/The%20Vista%20at%20Shaw/all/2019-12-19"
## [2] "https://eatatstate.msu.edu/menu/The%20Vista%20at%20Shaw/all/2019-12-20"
## [3] "https://eatatstate.msu.edu/menu/The%20Vista%20at%20Shaw/all/2019-12-21"
## [4] "https://eatatstate.msu.edu/menu/The%20Vista%20at%20Shaw/all/2019-12-22"
## [5] "https://eatatstate.msu.edu/menu/The%20Vista%20at%20Shaw/all/2019-12-23"
## [6] "https://eatatstate.msu.edu/menu/The%20Vista%20at%20Shaw/all/2019-12-24"

Dates and Time

We’ll want to clean up the data with regular expressions and repeat “Lunch” and “Dinner” for the dates and different dining halls.

# Date
date <- rep(dates, times = 2 * dining_hall_no)

# Cafe

no_dates <- length(dates) 
names <- str_replace_all(dining_halls, "%20|\\/all\\/"," ")
cafe <- rep(names, each = no_dates, times = 2)

# Time
time <- rep(c("Lunch", "Dinner"), each = no_dates * dining_hall_no)
time
##  [1] "Lunch"  "Lunch"  "Lunch"  "Lunch"  "Lunch"  "Lunch"  "Lunch"  "Lunch" 
##  [9] "Lunch"  "Lunch"  "Lunch"  "Lunch"  "Lunch"  "Lunch"  "Lunch"  "Lunch" 
## [17] "Lunch"  "Lunch"  "Lunch"  "Lunch"  "Lunch"  "Lunch"  "Lunch"  "Lunch" 
## [25] "Lunch"  "Lunch"  "Lunch"  "Lunch"  "Lunch"  "Lunch"  "Lunch"  "Lunch" 
## [33] "Lunch"  "Dinner" "Dinner" "Dinner" "Dinner" "Dinner" "Dinner" "Dinner"
## [41] "Dinner" "Dinner" "Dinner" "Dinner" "Dinner" "Dinner" "Dinner" "Dinner"
## [49] "Dinner" "Dinner" "Dinner" "Dinner" "Dinner" "Dinner" "Dinner" "Dinner"
## [57] "Dinner" "Dinner" "Dinner" "Dinner" "Dinner" "Dinner" "Dinner" "Dinner"
## [65] "Dinner" "Dinner"

Scrape

Here I used the rvest package and combined it with purrr so I read multiple URLs and return the the text so we can put it into a data frame.

# Menu 
menu <- all_url %>%   
 map(~read_html(.x) %>% 
      html_nodes(".meal-title") %>% 
      html_text()) 

Create a data frame

We can bind the data into a data frame so we can easily filter and find menus that we like.

food <- tibble(date, cafe, time, menu) %>% 
  unnest(menu) 

dim(food)
food
## [1] 2349    4
datecafetimemenu
2018-10-05The Vista at ShawLunchChicken Pasta Primavera
2018-10-05The Vista at ShawLunchCorn Muffin
2018-10-05The Vista at ShawLunchCuban Black Bean and Pork Chili
2018-10-05The Vista at ShawLunchChocolate Chip Cookie
2018-10-05The Vista at ShawLunchDouble Chocolate Chip Cookie
2018-10-05The Vista at ShawLunchM&M Cookie
2018-10-05The Vista at ShawLunchSnickerdoodle Cookie
2018-10-05The Vista at ShawLunchEggplant Lentil Chili
2018-10-05The Vista at ShawLunchFruit Bowl
2018-10-05The Vista at ShawLunchSmokey BBQ Tofu Sandwich
2018-10-05The Vista at ShawLunchSteamed Corn
2018-10-05The Vista at ShawLunchSweet Potato Fries
2018-10-05The Vista at ShawLunchWild and Jasmine Rice Blend
2018-10-05The Vista at ShawLunchBeef Hot Dog
2018-10-05The Vista at ShawLunchBreaded Chicken Patty
2018-10-05The Vista at ShawLunchBurger Bar
2018-10-05The Vista at ShawLunchFrench Fries
2018-10-05The Vista at ShawLunchGrilled Cheese
2018-10-05The Vista at ShawLunchBaked Fresh Fish
2018-10-05The Vista at ShawLunchBreadsmith’s Bakery Peasant Roll
2018-10-05The Vista at ShawLunchHoney Butter
2018-10-05The Vista at ShawLunchOrange Mustard Glaze
2018-10-05The Vista at ShawLunchRoasted Red Potatoes
2018-10-05The Vista at ShawLunchSauteed Capri Vegetables
2018-10-05The Vista at ShawLunchBrown Rice
2018-10-05The Vista at ShawLunchGuinness Lamb Stew
2018-10-05The Vista at ShawLunchSteamed Baby Carrots with Parsley
2018-10-05The Vista at ShawLunchBasmati Rice
2018-10-05The Vista at ShawLunchCrab Rangoons
2018-10-05The Vista at ShawLunchLo Mein
2018-10-05The Vista at ShawLunchPeking Pork
2018-10-05The Vista at ShawLunchSingapore Broth
2018-10-05The Vista at ShawLunchTofu
2018-10-06The Vista at ShawLunchCheese Pizza
2018-10-06The Vista at ShawLunchChicken Enchilada Soup
2018-10-06The Vista at ShawLunchPepperoni Pizza
2018-10-06The Vista at ShawLunchChocolate Chip Cookie
2018-10-06The Vista at ShawLunchDouble Chocolate Cookie
2018-10-06The Vista at ShawLunchSnickerdoodle Cookie
2018-10-06The Vista at ShawLunchFire Roasted Tomato Salsa
2018-10-06The Vista at ShawLunchRoasted Sweet Corn Soup
2018-10-06The Vista at ShawLunchTortilla Chips
2018-10-06The Vista at ShawLunchVegan Nacho Casserole
2018-10-06The Vista at ShawLunchWild and Jasmine Rice Blend
2018-10-06The Vista at ShawLunchBasil Roasted Chicken
2018-10-06The Vista at ShawLunchBreadsmith’s Bakery Peasant Roll
2018-10-06The Vista at ShawLunchConfetti Rice
2018-10-06The Vista at ShawLunchHoney Butter
2018-10-06The Vista at ShawLunchRoasted Lemon Thyme Carrots
2018-10-06The Vista at ShawLunchPork Pozole
2018-10-06The Vista at ShawLunchQuinoa
2018-10-06The Vista at ShawLunchSweet and Spicy Brussels Sprouts
2018-10-06The Vista at ShawLunchBeef Shiitake Broth
2018-10-06The Vista at ShawLunchBeef Sirloin Roast
2018-10-06The Vista at ShawLunchFried Pork Wontons
2018-10-06The Vista at ShawLunchJasmine Rice
2018-10-06The Vista at ShawLunchLo Mein
2018-10-06The Vista at ShawLunchSweet Ginger Sesame Sauce
2018-10-06The Vista at ShawLunchTofu
2018-10-07The Vista at ShawLunchBeef, Bean and Bacon Soup
2018-10-07The Vista at ShawLunchCheese Pizza
2018-10-07The Vista at ShawLunchPepperoni Pizza
2018-10-07The Vista at ShawLunchChocolate Chip Cookie
2018-10-07The Vista at ShawLunchDouble Chocolate Chip Cookie
2018-10-07The Vista at ShawLunchM&M Cookie
2018-10-07The Vista at ShawLunchSteamed Rice
2018-10-07The Vista at ShawLunchSweet Corn Macaroni and Cheese
2018-10-07The Vista at ShawLunchSweet Potato Fries
2018-10-07The Vista at ShawLunchVegan Chicken Tenders
2018-10-07The Vista at ShawLunchVegetable Minestrone Soup
2018-10-07The Vista at ShawLunchWild Ruby Rice Blend
2018-10-07The Vista at ShawLunchBreadsmith’s Bakery Peasant Roll
2018-10-07The Vista at ShawLunchHoney Butter
2018-10-07The Vista at ShawLunchJade Rice Blend
2018-10-07The Vista at ShawLunchPork Loin with Mushroom Sauce
2018-10-07The Vista at ShawLunchVegetable of the Day
2018-10-07The Vista at ShawLunchBourbon Chicken
2018-10-07The Vista at ShawLunchSteamed Broccoli Florets
2018-10-07The Vista at ShawLunchVegetable Fried Rice
2018-10-07The Vista at ShawLunchBasmati Rice
2018-10-07The Vista at ShawLunchGinger and Garlic Broth
2018-10-07The Vista at ShawLunchLo Mein
2018-10-07The Vista at ShawLunchPork Roast
2018-10-07The Vista at ShawLunchSaigon Sizzle Sauce
2018-10-07The Vista at ShawLunchTofu
2018-10-07The Vista at ShawLunchVegetable Egg Rolls
2018-10-08The Vista at ShawLunchBlack Bean Chili with Sausage
2018-10-08The Vista at ShawLunchCheese Stuffed Breadsticks
2018-10-08The Vista at ShawLunchShrimp and Crab Penne Alfredo
2018-10-08The Vista at ShawLunchChocolate Chip Cookie
2018-10-08The Vista at ShawLunchDouble Chocolate Chip Cookie
2018-10-08The Vista at ShawLunchOatmeal Raisin Cookie
2018-10-08The Vista at ShawLunchBasmati Rice
2018-10-08The Vista at ShawLunchGarlic Naan Bread
2018-10-08The Vista at ShawLunchLentil and Garbanzo Curry
2018-10-08The Vista at ShawLunchSteamed Snap Peas and Carrots
2018-10-08The Vista at ShawLunchVegan White Bean Chick’n Chili
2018-10-08The Vista at ShawLunchWild Ruby Rice Blend
2018-10-08The Vista at ShawLunchBeef Hot Dog
2018-10-08The Vista at ShawLunchBreaded Chicken Patty
2018-10-08The Vista at ShawLunchBurger Bar
2018-10-08The Vista at ShawLunchFrench Fries
2018-10-08The Vista at ShawLunchGrilled Cheese
2018-10-08The Vista at ShawLunchBreadsmith’s Bakery Peasant Roll
2018-10-08The Vista at ShawLunchHoney Butter
2018-10-08The Vista at ShawLunchJerk Pork Loin
2018-10-08The Vista at ShawLunchRoasted Sweet Potatoes
2018-10-08The Vista at ShawLunchSteamed Cauliflower and Carrots
2018-10-08The Vista at ShawLunchCaviar Medley Rice
2018-10-08The Vista at ShawLunchChili Lime Glaze
2018-10-08The Vista at ShawLunchRoasted Zucchini and Summer Squash
2018-10-08The Vista at ShawLunchSpicy Soy Marinated Chicken Thighs
2018-10-08The Vista at ShawLunchBeef Sirloin Roast
2018-10-08The Vista at ShawLunchJapanese Beef Curry Broth
2018-10-08The Vista at ShawLunchJasmine Rice
2018-10-08The Vista at ShawLunchLo Mein
2018-10-08The Vista at ShawLunchPork Dumplings
2018-10-08The Vista at ShawLunchSpicy Szechuan Sauce
2018-10-08The Vista at ShawLunchTofu
2018-10-09The Vista at ShawLunchCheese Stuffed Breadsticks
2018-10-09The Vista at ShawLunchCheese Tortellini w/ Red Pepper Marinara
2018-10-09The Vista at ShawLunchChicken Cordon Bleu Soup
2018-10-09The Vista at ShawLunchChocolate Chip Cookie
2018-10-09The Vista at ShawLunchDouble Chocolate Chip Cookie
2018-10-09The Vista at ShawLunchOatmeal Raisin Cookie
2018-10-09The Vista at ShawLunchBlackened Tofu
2018-10-09The Vista at ShawLunchCauliflower Salad
2018-10-09The Vista at ShawLunchFettuccine Pasta
2018-10-09The Vista at ShawLunchGarlic and Herb Spaghetti Sauce
2018-10-09The Vista at ShawLunchMushroom Barley Soup
2018-10-09The Vista at ShawLunchRoasted Asparagus
2018-10-09The Vista at ShawLunchSundried Tomato Alfredo Sauce
2018-10-09The Vista at ShawLunchWild Ruby Rice Blend
2018-10-09The Vista at ShawLunchBeef Hot Dog
2018-10-09The Vista at ShawLunchBreaded Chicken Patty
2018-10-09The Vista at ShawLunchBurger Bar
2018-10-09The Vista at ShawLunchFrench Fries
2018-10-09The Vista at ShawLunchGrilled Cheese
2018-10-09The Vista at ShawLunchBreadsmith’s Bakery Peasant Roll
2018-10-09The Vista at ShawLunchButtered Peas and Carrots
2018-10-09The Vista at ShawLunchCherry Chicken
2018-10-09The Vista at ShawLunchCherry Pecan Wild Rice
2018-10-09The Vista at ShawLunchHoney Butter
2018-10-09The Vista at ShawLunchLime Cilantro Yogurt Sauce
2018-10-09The Vista at ShawLunchSteak Fajita Salad
2018-10-09The Vista at ShawLunchBasmati Rice
2018-10-09The Vista at ShawLunchBoneless Skinless Chicken Thighs
2018-10-09The Vista at ShawLunchLo Mein
2018-10-09The Vista at ShawLunchMushroom Broth
2018-10-09The Vista at ShawLunchThai Peanut Sauce
2018-10-09The Vista at ShawLunchThai Vegetable Potstickers
2018-10-09The Vista at ShawLunchTofu
2018-10-10The Vista at ShawLunchBreadsticks
2018-10-10The Vista at ShawLunchBuffalo Chicken Pasta
2018-10-10The Vista at ShawLunchLentil and Chorizo Soup
2018-10-10The Vista at ShawLunchChocolate Chip Cookie
2018-10-10The Vista at ShawLunchDouble Chocolate Chip Cookie
2018-10-10The Vista at ShawLunchSugar Cookie
2018-10-10The Vista at ShawLunchFrench Fries
2018-10-10The Vista at ShawLunchRoasted Red Pepper Aioli
2018-10-10The Vista at ShawLunchSteamed Mixed Vegetables
2018-10-10The Vista at ShawLunchTomato Basil Soup
2018-10-10The Vista at ShawLunchVegan Chick’n Sandwich
2018-10-10The Vista at ShawLunchWild Ruby Rice Blend
2018-10-10The Vista at ShawLunchBeef Hot Dog
2018-10-10The Vista at ShawLunchBreaded Chicken Patty
2018-10-10The Vista at ShawLunchBurger Bar
2018-10-10The Vista at ShawLunchFrench Fries
2018-10-10The Vista at ShawLunchGrilled Cheese
2018-10-10The Vista at ShawLunchBreadsmith’s Bakery Peasant Roll
2018-10-10The Vista at ShawLunchChicken Pasta Primavera
2018-10-10The Vista at ShawLunchHoney Butter
2018-10-10The Vista at ShawLunchRoasted Zucchini and Summer Squash
2018-10-10The Vista at ShawLunchCilantro Lime Rice
2018-10-10The Vista at ShawLunchColeslaw
2018-10-10The Vista at ShawLunchRoasted Fajita Vegetables
2018-10-10The Vista at ShawLunchTortilla Encrusted Fresh Fish
2018-10-10The Vista at ShawLunchCrab Rangoons
2018-10-10The Vista at ShawLunchJasmine Rice
2018-10-10The Vista at ShawLunchLo Mein
2018-10-10The Vista at ShawLunchMiso Broth
2018-10-10The Vista at ShawLunchPork Roast
2018-10-10The Vista at ShawLunchSweet Onion Teriyaki Sauce
2018-10-10The Vista at ShawLunchTofu
2018-10-11The Vista at ShawLunchBrick Oven Chicken Pot Pie
2018-10-11The Vista at ShawLunchSpicy Steak Chili
2018-10-11The Vista at ShawLunchChocolate Chip Cookie
2018-10-11The Vista at ShawLunchDouble Chocolate Chip Cookie
2018-10-11The Vista at ShawLunchSugar Cookie
2018-10-11The Vista at ShawLunchApple Snicker Bar Salad
2018-10-11The Vista at ShawLunchBreadsticks
2018-10-11The Vista at ShawLunchCheese Tortellini with Alfredo
2018-10-11The Vista at ShawLunchItalian Vegetable Saute
2018-10-11The Vista at ShawLunchOnion Soup
2018-10-11The Vista at ShawLunchRoasted Red Pepper Marinara
2018-10-11The Vista at ShawLunchSpaghetti Noodles
2018-10-11The Vista at ShawLunchWild Ruby Rice Blend
2018-10-11The Vista at ShawLunchBeef Hot Dog
2018-10-11The Vista at ShawLunchBreaded Chicken Patty
2018-10-11The Vista at ShawLunchBurger Bar
2018-10-11The Vista at ShawLunchFrench Fries
2018-10-11The Vista at ShawLunchGrilled Cheese
2018-10-11The Vista at ShawLunchBeef and Noodles
2018-10-11The Vista at ShawLunchBreadsmith’s Bakery Peasant Roll
2018-10-11The Vista at ShawLunchHoney Butter
2018-10-11The Vista at ShawLunchSteamed Broccoli and Cauliflower
2018-10-11The Vista at ShawLunchGarlic Buttered Rice
2018-10-11The Vista at ShawLunchRoasted Ginger Curry Carrots
2018-10-11The Vista at ShawLunchTandoori Chicken
2018-10-11The Vista at ShawLunchAsian Pineapple Sauce
2018-10-11The Vista at ShawLunchBasmati Rice
2018-10-11The Vista at ShawLunchCrab Meat
2018-10-11The Vista at ShawLunchLo Mein
2018-10-11The Vista at ShawLunchPork Wonton
2018-10-11The Vista at ShawLunchSeafood and Bok Choy Broth
2018-10-11The Vista at ShawLunchShrimp
2018-10-11The Vista at ShawLunchTofu
2018-10-12The Vista at ShawLunchGarlic Breadsticks
2018-10-12The Vista at ShawLunchMacaroni and Cheese
2018-10-12The Vista at ShawLunchPepper Jack Crab Soup
2018-10-12The Vista at ShawLunchChocolate Chip Cookie
2018-10-12The Vista at ShawLunchDouble Chocolate Chip Cookie
2018-10-12The Vista at ShawLunchM&M Cookie
2018-10-12The Vista at ShawLunchAnaheim Chili Soup
2018-10-12The Vista at ShawLunchApple Baked Beans
2018-10-12The Vista at ShawLunchBroccoli Pasta Salad
2018-10-12The Vista at ShawLunchCorn Fritters
2018-10-12The Vista at ShawLunchVegan BBQ Beef Tips
2018-10-12The Vista at ShawLunchWild Ruby Rice Blend
2018-10-12The Vista at ShawLunchBeef Hot Dog
2018-10-12The Vista at ShawLunchBreaded Chicken Patty
2018-10-12The Vista at ShawLunchBurger Bar
2018-10-12The Vista at ShawLunchFrench Fries
2018-10-12The Vista at ShawLunchGrilled Cheese
2018-10-12The Vista at ShawLunchBreadsmith’s Bakery Peasant Roll
2018-10-12The Vista at ShawLunchFresh Fish with Garlic Herb Butter
2018-10-12The Vista at ShawLunchHoney Butter
2018-10-12The Vista at ShawLunchRoasted Root Vegetables
2018-10-12The Vista at ShawLunchSteamed Rice
2018-10-12The Vista at ShawLunchSauteed Bok Choy
2018-10-12The Vista at ShawLunchSesame Brown Rice
2018-10-12The Vista at ShawLunchSesame Chili Crusted Chicken
2018-10-12The Vista at ShawLunchStir Fry Sauce
2018-10-12The Vista at ShawLunchBangkok Pork Broth
2018-10-12The Vista at ShawLunchDuck Potstickers
2018-10-12The Vista at ShawLunchJasmine Rice
2018-10-12The Vista at ShawLunchLo Mein
2018-10-12The Vista at ShawLunchOrange Citrus Sauce
2018-10-12The Vista at ShawLunchPork Roast
2018-10-12The Vista at ShawLunchTofu
2018-10-05The Gallery at Snyder PhillipsLunchChocolate Chip Cookie
2018-10-05The Gallery at Snyder PhillipsLunchChocolate Peanut Butter Marble Cake
2018-10-05The Gallery at Snyder PhillipsLunchIced Brownie
2018-10-05The Gallery at Snyder PhillipsLunchSnickerdoodle Cookie
2018-10-05The Gallery at Snyder PhillipsLunchVegan Chocolate Cake
2018-10-05The Gallery at Snyder PhillipsLunchBattered Haddock
2018-10-05The Gallery at Snyder PhillipsLunchBeyond Meat Vegan Burger
2018-10-05The Gallery at Snyder PhillipsLunchBreaded Chicken Patty
2018-10-05The Gallery at Snyder PhillipsLunchBurger
2018-10-05The Gallery at Snyder PhillipsLunchCheeseburger
2018-10-05The Gallery at Snyder PhillipsLunchChef’s Choice
2018-10-05The Gallery at Snyder PhillipsLunchChipotle Mayonnaise
2018-10-05The Gallery at Snyder PhillipsLunchDill Pickle Chips
2018-10-05The Gallery at Snyder PhillipsLunchFrench Fries
2018-10-05The Gallery at Snyder PhillipsLunchGrilled Cheese
2018-10-05The Gallery at Snyder PhillipsLunchGrilled Chicken Breast
2018-10-05The Gallery at Snyder PhillipsLunchIceberg Lettuce
2018-10-05The Gallery at Snyder PhillipsLunchLemons
2018-10-05The Gallery at Snyder PhillipsLunchMayonnaise
2018-10-05The Gallery at Snyder PhillipsLunchMustard
2018-10-05The Gallery at Snyder PhillipsLunchRed Onions
2018-10-05The Gallery at Snyder PhillipsLunchSweet Baby Ray’s BBQ Sauce
2018-10-05The Gallery at Snyder PhillipsLunchTartar Sauce
2018-10-05The Gallery at Snyder PhillipsLunchTomatoes
2018-10-05The Gallery at Snyder PhillipsLunchBacon
2018-10-05The Gallery at Snyder PhillipsLunchBattered Haddock
2018-10-05The Gallery at Snyder PhillipsLunchBeanless Chili
2018-10-05The Gallery at Snyder PhillipsLunchCheddar Cheese
2018-10-05The Gallery at Snyder PhillipsLunchCheese Sauce
2018-10-05The Gallery at Snyder PhillipsLunchFrench Fries
2018-10-05The Gallery at Snyder PhillipsLunchMushrooms
2018-10-05The Gallery at Snyder PhillipsLunchPepper Jack Cheese
2018-10-05The Gallery at Snyder PhillipsLunchPhilly Beef Sandwich
2018-10-05The Gallery at Snyder PhillipsLunchProvolone Cheese
2018-10-05The Gallery at Snyder PhillipsLunchSauteed Bell Peppers and Onions
2018-10-05The Gallery at Snyder PhillipsLunchSwiss Cheese
2018-10-05The Gallery at Snyder PhillipsLunchCaramel Apple Pizza
2018-10-05The Gallery at Snyder PhillipsLunchCheese Pizza
2018-10-05The Gallery at Snyder PhillipsLunchPepperoni Pizza
2018-10-05The Gallery at Snyder PhillipsLunchFarro
2018-10-05The Gallery at Snyder PhillipsLunchFattoush Salad
2018-10-05The Gallery at Snyder PhillipsLunchJasmine Rice
2018-10-05The Gallery at Snyder PhillipsLunchSteamed Peas
2018-10-05The Gallery at Snyder PhillipsLunchTeriyaki Tofu and Vegetable Yakitori
2018-10-05The Gallery at Snyder PhillipsLunchVegan French Onion Soup
2018-10-05The Gallery at Snyder PhillipsLunchWoody’s Garlic Scallion Hummus
2018-10-05The Gallery at Snyder PhillipsLunchWoody’s Original Hummus
2018-10-05The Gallery at Snyder PhillipsLunchWoody’s Tabbouleh Salad
2018-10-05The Gallery at Snyder PhillipsLunchWoody’s Thin Pita Bread
2018-10-05The Gallery at Snyder PhillipsLunchCorn O’Brien

I made it on Monday this week and to my surprise I saw that they would be serving it today for dinner in Landon!

food %>% 
  filter(str_detect(menu, "Presidential"))
## # A tibble: 1 x 4
##   date       cafe                       time   menu                
##   <date>     <chr>                      <chr>  <chr>               
## 1 2018-10-05 Heritage Commons at Landon Dinner Presidential Chicken

We can also filter to look at the menu for today only.

food %>% 
  filter(date == today())
## # A tibble: 0 x 4
## # … with 4 variables: date <date>, cafe <chr>, time <chr>, menu <chr>

Wordcloud

Since we have a tidy data frame of all the dining halls we can use the tidytext package from Julia Silge and David Robinson to tokenize the menu and make a word cloud. First I used the palette from MSU’s website and set it as an object pal. Next we will unnest the tokens from the food data frame and count up the most frequent words. We can remove filler words with an anti_join() command and then tell R to create a wordcloud!

library(tidytext)
library(wordcloud)
library(RColorBrewer)

# MSU palette colors  
pal <- c("#97A2A2","#F08521","#6E005F","#F08521","#97A2A2","#0DB14B")

set.seed(1234)

food %>% 
  unnest_tokens(menu, menu) %>% 
  count(menu, sort = TRUE) %>% 
  rename(word = menu) %>% 
  anti_join(stop_words, by = "word") %>% 
  with(wordcloud(word, n, random.order = FALSE, max.words = 40, color = pal,fixed.asp = TRUE))

Shiny Dashboard

Now that we learned how to make a wordcloud, scrape the menu into a tidy data frame we can work on making a interact with the data by making a shiny dashboard.

library(shiny)
library(shinydashboard)

ui <- dashboardPage(skin = "green",
  dashboardHeader(title = "Eat at State"),
  dashboardSidebar( selectInput(inputId = 'dininghall',
                  label = 'Choose Dining Hall:',
                  choices = c("All","The Vista at Shaw ",
                              "The Gallery at Snyder Phillips ",
                              "Heritage Commons at Landon "))
  ),
  
  dashboardBody(
    # Boxes need to be put in a row (or column)
    fluidRow(
      box(dataTableOutput("menu"),title = "MSU Dining Menu",
          width = 12, status = "primary")
      )
    )
  )

server <- function(input, output) {
  
   menu <- reactive({
    if(input$dininghall == "All")
        return(food)
    else
      food %>% 
       filter(cafe %in% input$dininghall)
  })

  output$menu <- renderDataTable(menu())
}

shinyApp(ui, server)
Eat at State Shiny Dashboard

Eat at State Shiny Dashboard

Presidential Chicken!

Landon I had the idea to scrape for presidential chicken on Monday this week and I was thrilled that Landon had it for dinner on Friday. Now that I was able to go I decided to create this blog post to share with everyone!

Avatar
Sean Nguyen
Incoming Data Science Fellow

Related