Skip to content

Instantly share code, notes, and snippets.

@jenniferthompson
Created February 13, 2018 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jenniferthompson/7569c1a3a2b4888d93914c8c9862dd1e to your computer and use it in GitHub Desktop.
Save jenniferthompson/7569c1a3a2b4888d93914c8c9862dd1e to your computer and use it in GitHub Desktop.
R script to summarize my grocery list for New Years Brunch 2018
## Doesn't include: salt, pepper, oil, vanilla, honey, baking soda, nutmeg, Dijon mustard, red wine vinegar, spices I know I have
library(tidyverse)
## How many batches of chocolate babka muffins? I originally started with 2 but
## more people RSVPed...
babka_batches <- 3
brunch_list <- tribble(
~ Dish, ~ Homemade, ~ Time, ~ Ingredients,
"Granola", "Yes", 60, list("oats" = list(3, "cups"),
"pecans" = list(1, "cups"),
"maple syrup" = list(0.5, "cups"),
"eggs" = list(1, NA),
"dried fruit" = list(1.5, "cups")),
"Yogurt", "No", 0, list("yogurt" = list(3, "TJ containers")),
"Chorizo frittata", "Yes", 90, list("chorizo" = list(2, "packs"),
"leeks" = list(1, NA),
"white potatoes" = list(2, "lbs"),
"eggs" = list(20, NA)),
"Spinach frittata", "Yes", 90, list("spinach" = list(1, "bag"),
"leeks" = list(2, NA),
"garlic" = list(4, "cloves"),
"eggs" = list(20, NA)),
## Chocolate wafers are for the babka muffins
"Chocolate wafers", "Yes", 60, list("AP flour" = list(1.5, "cups"),
"cocoa powder" = list(0.75, "cups"),
"sugar" = list(1.125, "cups"),
"butter" = list(1.75, "sticks"),
"whole milk" = list(3 / 16, "cups")),
"Babka muffins", "Yes", 180, list("active dry yeast" = list(1 * babka_batches, "envelopes"),
"AP flour" = list(3.5 * babka_batches, "cups"),
"sugar" = list(0.25 * babka_batches, "cups"),
"butter" = list(0.5 * babka_batches, "sticks"),
"whole milk" = list(0.5 * babka_batches, "cups"),
"eggs" = list(2 * babka_batches, NA),
"milk chocolate" = list(9 * babka_batches, "oz"),
"bittersweet chocolate" = list(3 * babka_batches, "oz"),
"butter" = list(1.5 * babka_batches, "sticks"),
"AP flour" = list(0.5 * babka_batches, "cups"),
"brown sugar" = list(0.5 * babka_batches, "cups"),
"butter" = list(0.5 * babka_batches, "sticks")),
"Kale salad", "Yes", 45, list("kale" = list(3, "Publix bags"),
"hazelnuts" = list(1, "bag"),
"cranberries" = list(1, "bag")),
"Brussels salad", "Yes", 15, list("shaved Brussels sprouts" = list(3, "bags"),
"pomegranate seeds" = list(1, "TJ box"),
"sliced almonds" = list(0.5, "bag"),
"shallot" = list(1, "bag")),
## Dressing for both salads
"Vinaigrette", "Yes", 15, list("orange juice" = list(8, "oz"),
"lemon juice" = list(8, "oz"),
"olive oil" = list(16, "oz")),
"Spiced pecans", "Yes", 30, list("pecans" = list(1, "bag")),
"Paper goods", "No", 0, list("plates" = list(30, NA),
"bowls" = list(30, NA),
"cups" = list(30, NA),
"forks" = list(30, NA),
"spoons" = list(30, NA),
"knives" = list(30, NA),
"sugar packets" = list(1, "box"))
)
## Multiply everything in the chocolate babka muffin ingredient list by the
## number of batches we need
## I need a grocery list. How much of each thing do I need?
## Make a data.frame with one row per instance and quantity
ingredient_info <- tibble(
Ingredient = names(flatten(brunch_list$Ingredients)),
Amount = map_dbl(flatten(brunch_list$Ingredients), ~pluck(., 1)),
Unit = map_chr(flatten(brunch_list$Ingredients), ~pluck(., 2))
)
## Grocery list
grocery_list <- ingredient_info %>%
group_by(Ingredient, Unit) %>%
summarise(Total = sum(Amount)) %>%
## Make it real nerdy: Assign each ingredient to a section of the store,
## in order that I shop (for now, mash up Publix and Trader Joe's layout)
mutate(
Section = factor(
case_when(
Ingredient %in% c("leeks", "garlic", "shallot", "kale",
"pomegranate seeds", "shaved Brussels sprouts",
"white potatoes", "spinach", "lemon juice",
"orange juice") ~ 1,
Ingredient %in% c("chorizo") ~ 2,
Ingredient %in% c("active dry yeast", "AP flour", "oats",
"bittersweet chocolate", "brown sugar",
"cocoa powder", "sugar", "maple syrup",
"milk chocolate", "olive oil") ~ 3,
Ingredient %in% c("butter", "whole milk", "yogurt", "eggs") ~ 4,
Ingredient %in% c("cranberries", "dried fruit", "hazelnuts", "pecans",
"sliced almonds") ~ 5,
Ingredient %in%
c("plates", "cups", "bowls", "forks", "knives", "spoons", "sugar packets") ~ 6,
TRUE ~ 7
),
levels = 1:7,
## Include a "missed this" level in case I forgot anything!
labels =
c("Produce", "Meats", "Baking", "Dairy", "Fruit/nuts",
"Paper goods", "Missed this")
),
## Add a column for where I prefer to buy each thing
Store = factor(
case_when(
Ingredient %in% c(
"pomegranate seeds", "white potatoes", "chorizo", "maple syrup",
"olive oil", "butter", "whole milk", "cranberries", "yogurt",
"dried fruit", "hazelnuts", "pecans", "sliced almonds") ~ 1,
Ingredient %in% c("eggs") ~ 2,
Ingredient %in%
c("kale", "leeks", "lemon juice", "active dry yeast", "oats",
"brown sugar", "sugar") ~ 3,
TRUE ~ 4
),
levels = 1:4,
labels = c("Trader Joe's", "Whole Foods", "Publix", "Wherever")
)
) %>%
arrange(Store, Section, Ingredient) %>%
select(Store, Section, Ingredient, Total, Unit)
print(grocery_list, n = Inf)
## Recipes:
## Chocolate wafers from Smitten Kitchen:
## https://smittenkitchen.com/2009/03/homemade-chocolate-wafers-icebox-cupcakes/
## Chocolate babka muffins from Joy the Baker:
## http://joythebaker.com/2017/12/chocolate-babka-pull-apart-muffins/
## Gingerbread spiced pecans from Mel Joulwan:
## https://meljoulwan.com/2017/11/21/gingerbread-spiced-pecans/
## https://meljoulwan.com/2017/11/21/gingerbread-spice-blend/
## Kale salad blatantly ripped off from Burger Up, Nashville http://www.burger-up.com/menu
## Brussels sprout salad inspired by Smitten Kitchen
## https://smittenkitchen.com/2016/11/brussels-sprouts-apple-and-pomegranate-salad/
## Citrus vinaigrette via Nom Nom Paleo's first cookbook
## Granola via Smitten Kitchen's first cookbook
## Frittatas: I made those up, inspired by many things
#### try modify_depth() for modifying amount of babka recipes?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment