-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexercise_01.Rmd
47 lines (28 loc) · 1.91 KB
/
exercise_01.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
title: "Exercise 1"
---
## Directions
For the workshop, we've prebuilt a data set that has information about menus in Duke's Brodhead Center from three restaurants. With the instructor, create a new R Notebook, load the *tidyverse* package, and **load the dining hall dataset**, *as a tibble*.
1. From the File menu, open a New R Notebook: `File > New File > R Notebook`
1. Reading the preloaded directions in your new script, add a code chunk at/around line 20. (Hint: *Ctrl+Alt+I*)
1. Load the `tidyverse` package. In that code-chunk, type: `library(tidyverse)` and **run the code chunk**.
1. Insert a code chunk and load the practice data: `read_csv("data/brodheadCenter.csv")`
- Remember to assign the imported data to an object name, e.g. "brodhead"
1. Now you are ready to make new code chunks and follow the steps in Exercise 1 (below).
In this exercise you'll practice the `dplyr` verbs (i.e. *functions*) mentioned in the demonstration.
- `arrange()`
- `filter()`
- `mutate()`
- `select()`
- `count()`
## Exercise: 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?
2. Which restaurant has the most expensive item(s)? What are those item(s)?
3. At the Brodhead Center, how many of the entrees (found in the `menuType` variable) cost eight dollars?
4. 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.
5. How many entrees are in the dataset (`menuType` variable)? How many desserts
## Answers
See [the answers](answers.Rmd) to the above section
## Quiz
Take the [interactive quiz](https://libjohn.shinyapps.io/intro2r_quizzes/#section-data-wrangling-with-dplyr)