23 Chipotle purrr
Readings
Guided Instruction
These videos provide a demonstration of purrr and hints for setting up and solving the tasks.
Enrichment Reading
Here is some useful (optional) reading if you want to repeat code and apply it to multiple columns. This won’t be necessary for our tasks, but is very common in practice.
Chapter 26.2 Modifying Multiple Columns: R for Data Science (2nd ed)
You got your dream job working as a data analyst for one of your favorite restaurants, Chipotle! Chipotle is planning to run a large 1 or 2 day promotion. They would like the promotion to take place when the restaurant is busiest. They have gathered restaurant level data that you can use to answer the question, “what is the busiest day in the restaurant?”
This task asks you to conduct the analysis/visualization using two different units of measure. The decision about what unit of measure to use can mask or reveal key insights.
Read in the restaurant level data: https://byuistats.github.io/M335/data/chipotle_reduced.csv
- Here is a data dictionary
Create a visualization of the data that can be used to decide what day(s) to run the promotion.
- Apply one of the functions from the previous task to each row of the dataset using
map_*()
. (You may need to do a little cleaning/wrangling first) - Use the dataset to create your visualization to support your conclusion (You may need to do a little cleaning/wrangling first)
- Write about what an “observation” represents in this newly created dataset.
- Apply one of the functions from the previous task to each row of the dataset using
Write a sentence or two containing a recommendation to Chipotle leadership about when to run the promotion based on the graphed data.
Repeat bullets 1& 2 above, however if you you applied Function 1 to do the steps above, use Function 2 for this portion. If you used Function 2 to do the previous bullets, now use Function 1 for this portion.
Ensure both of your visualizations are “presentation worthy”.
Write a paragraph or two to address the following points:
- Now that you have seen both graphs, make a recommendation regarding which day(s) of the week Chipotle’s big promotion should run.
- Explain which visualization was most influential in your decision. In other words, which unit of measure (store count of busiest day, or count of inidividual visits) is most useful. If you think both are valuable, explain why.
- Mention any other worthy insights.
After all your hard work, you just received notice that you will be put on a different project and a co-worker will pick up this analysis where you left off. The best way to store the data so that this nested list structure is still in place when you hand it off is to give them an r dataset file. Save your dataset as a
.rds
file. This dataset should have each restaurant as a row and a list column of nested tibbles containing the visit counts for day of the week.Render your
.qmd
and push your.rds
data file,.qmd
,.md
and.html
file into your GitHub repository.
Submit
In I-learn submit a link to the .md
file on GitHub.