PART ONE: Loading Data

For the workshop, we’ve prebuilt a data set that has information about menus from three restaurants in Duke’s Brodhead Center.

  1. Using what we’ve you’ve seen in class, if brodheadCenter.csv is a csv file, how would you load the file into a new object called brodhead?
## -- Attaching packages -------- tidyverse 1.2.1 --
## v ggplot2 3.2.1     v purrr   0.3.2
## v tibble  2.1.3     v dplyr   0.8.3
## v tidyr   1.0.0     v stringr 1.4.0
## v readr   1.3.1     v forcats 0.4.0
## -- Conflicts ----------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
## Parsed with column specification:
## cols(
##   name = col_character(),
##   type = col_character(),
##   menuType = col_character(),
##   itemType = col_character(),
##   itemName = col_character(),
##   cost = col_double(),
##   rating = col_double()
## )
  1. What data structure is brodhead?
## [1] "spec_tbl_df" "tbl_df"      "tbl"         "data.frame"
  1. Take a look at the structure of the brodhead object.
    • How many observations (rows) are there?
    • How many variables (columns) are there?
    • How many of the variables are numeric data?
## Observations: 59
## Variables: 7
## $ name     <chr> "Devils Krafthouse", "Devils Krafthouse", "Devils Kra...
## $ type     <chr> "bar and grill", "bar and grill", "bar and grill", "b...
## $ menuType <chr> "appetizer", "appetizer", "appetizer", "appetizer", "...
## $ itemType <chr> "snack", "snack", "snack", "snack", "snack", "snack",...
## $ itemName <chr> "sweet potato tots", "french fries", "quesadillas", "...
## $ cost     <dbl> 4, 4, 6, 8, 7, 8, 9, 4, 9, 9, 9, 8, 4, 7, 7, 7, 8, 8,...
## $ rating   <dbl> 8, 10, 5, 6, 7, 8, 5, 6, 5, 5, 6, 6, 8, 6, 7, 5, 6, 5...

PART TWO: Data Wrangling

All of the following questions are based on the sample of restaurants represented in the dataset which is accurate as of September 2, 2016.

  1. Which restaurant has the lowest cost item and what is the item?
  1. Which restaurant has the most expensive item(s)? What are those item(s)?
  1. At the Brodheat Center, how many of the entrees (found in the menuType variable) cost eight dollars?
  1. The head of Duke dining is considering reducing prices at the Brodhead Center. Using what we’ve learned in class, write a line of code that will calculate a new variable (halfPrice) that contains items at half price.
  1. How many entrees are in the dataset (menuType variable)? How many desserts
 
R We Having Fun Yet‽ -- Learning Series
Data & Visualization Services
Duke University Libraries
C bn
Shareable via Creative Commons: CC By-NC