Skip to contents
library(autorecipes)
#> 
#> Attaching package: 'autorecipes'
#> The following objects are masked from 'package:base':
#> 
#>     units, weekdays
library(magrittr)

Background

As an unadventurous, by-the-recipe cook, I had accumulated a set of ~25 go-to meals that were chosen from each week. Over time, this selection became repetitive, which motivated the development of autorecipes and autogroceries. This package, autorecipes, automates the task of creating a weekly meal plan and corresponding shopping list of ingredients. autogroceries automates the ordering of the ingredients.


Basic usage

Example recipes

autorecipes defines a RecipeBook-class that stores the names and ingredients of recipes. autorecipes also includes a set of 26 example recipes in autorecipes::recipebook_example.


recipebook <- recipebook_example

class(recipebook)
#> [1] "RecipeBook"
#> attr(,"package")
#> [1] "autorecipes"

recipes(recipebook) %>% head()
#> # A tibble: 6 × 5
#>   index names                                       ingredients fav   last_eaten
#>   <int> <chr>                                       <list>      <lgl> <date>    
#> 1     1 Akoori Eggs with Spinach & Potato           <Ingrdnts>  FALSE NA        
#> 2     2 Crispy Duck with Fava Beans & Caramelised … <Ingrdnts>  FALSE NA        
#> 3     3 Chicken with Rosemary Plumns                <Ingrdnts>  FALSE NA        
#> 4     4 Chickpea & Sweet Potato Masala              <Ingrdnts>  FALSE NA        
#> 5     5 Gaucho Steaks with Chimichurri Salad        <Ingrdnts>  FALSE NA        
#> 6     6 Chipotle Bean Taco Salad                    <Ingrdnts>  FALSE NA


Set your favourite recipes

autorecipes allows users to set their favorite recipes using add_favourites() and rm_favourites(). This information can be used to determine the subset of recipes that will enter your meal plan.


# set the first 3 recipes as favourites
recipebook <- add_favourites(recipebook, 1:3)

recipes(recipebook) %>% head()
#> # A tibble: 6 × 5
#>   index names                                       ingredients fav   last_eaten
#>   <int> <chr>                                       <list>      <lgl> <date>    
#> 1     1 Akoori Eggs with Spinach & Potato           <Ingrdnts>  TRUE  NA        
#> 2     2 Crispy Duck with Fava Beans & Caramelised … <Ingrdnts>  TRUE  NA        
#> 3     3 Chicken with Rosemary Plumns                <Ingrdnts>  TRUE  NA        
#> 4     4 Chickpea & Sweet Potato Masala              <Ingrdnts>  FALSE NA        
#> 5     5 Gaucho Steaks with Chimichurri Salad        <Ingrdnts>  FALSE NA        
#> 6     6 Chipotle Bean Taco Salad                    <Ingrdnts>  FALSE NA


Create a meal plan

autorecipes allows you to create meal plan from your RecipeBook-class object. For this, you can set the days and meals you would like to plan for and also whether you only want to consider your favourite recipes.

create_meal_plan() can either select recipes randomly (method = "random") or take into account when you have last chosen a recipe for a previous meal plan (method = "auto").


recipebook <- create_meal_plan(
  recipebook,
  which_days = c("Wed", "Thurs", "Fri", "Sat", "Sun"), 
  which_meals = "Dinner",
  method = "auto",
  fav_only = TRUE
)

meal_plan(recipebook)
#> # A tibble: 5 × 7
#>   day   meal   recipe_index names                   ingredients fav   last_eaten
#>   <fct> <fct>         <int> <chr>                   <list>      <lgl> <date>    
#> 1 Wed   Dinner            3 Chicken with Rosemary … <Ingrdnts>  TRUE  2022-03-26
#> 2 Thurs Dinner            1 Akoori Eggs with Spina… <Ingrdnts>  TRUE  2022-03-26
#> 3 Fri   Dinner            2 Crispy Duck with Fava … <Ingrdnts>  TRUE  2022-03-26
#> 4 Sat   Dinner            3 Chicken with Rosemary … <Ingrdnts>  TRUE  2022-03-26
#> 5 Sun   Dinner            2 Crispy Duck with Fava … <Ingrdnts>  TRUE  2022-03-26


Create shopping list

create_shopping_list() aggregates all of the ingredients required to make your meal plan into a shopping list. The filter_method determines whether to remove store cupboard ingredients (e.g. salt) that you are unlikely to want to order every week.

The outputted shopping list is designed to then be inputted into autogroceries.


recipebook <- create_shopping_list(recipebook, filter_method = "minimal")

shopping_list(recipebook)
#> # A tibble: 18 × 2
#>    names                   n
#>    <chr>               <int>
#>  1 rosemary                2
#>  2 baby spinach            1
#>  3 chicken drumsticks      1
#>  4 chicken thighs          1
#>  5 chilli                  1
#>  6 coriander               1
#>  7 duck legs               1
#>  8 fava beans              1
#>  9 french beans            1
#> 10 garam masala            1
#> 11 mixed baby tomatoes     1
#> 12 plums                   1
#> 13 potatoes                1
#> 14 rainbow carrots         1
#> 15 salad potatoes          1
#> 16 savoy cabbage           1
#> 17 thyme                   1
#> 18 white wine              1


Session info

Show/hide
#> ─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R Under development (unstable) (2022-03-14 r81896)
#>  os       Ubuntu 20.04.4 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       UTC
#>  date     2022-03-26
#>  pandoc   2.17.1.1 @ /usr/local/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────
#>  package     * version    date (UTC) lib source
#>  autorecipes * 1.0.1      2022-03-26 [1] local
#>  bslib         0.3.1      2021-10-06 [1] CRAN (R 4.2.0)
#>  cachem        1.0.6      2021-08-19 [2] CRAN (R 4.2.0)
#>  cli           3.2.0      2022-02-14 [2] CRAN (R 4.2.0)
#>  crayon        1.5.1      2022-03-26 [2] CRAN (R 4.2.0)
#>  desc          1.4.1      2022-03-06 [2] CRAN (R 4.2.0)
#>  digest        0.6.29     2021-12-01 [2] CRAN (R 4.2.0)
#>  dplyr         1.0.8      2022-02-08 [2] CRAN (R 4.2.0)
#>  ellipsis      0.3.2      2021-04-29 [2] CRAN (R 4.2.0)
#>  evaluate      0.15       2022-02-18 [2] CRAN (R 4.2.0)
#>  fansi         1.0.3      2022-03-24 [2] CRAN (R 4.2.0)
#>  fastmap       1.1.0      2021-01-25 [2] CRAN (R 4.2.0)
#>  fs            1.5.2      2021-12-08 [2] CRAN (R 4.2.0)
#>  generics      0.1.2      2022-01-31 [2] CRAN (R 4.2.0)
#>  glue          1.6.2      2022-02-24 [2] CRAN (R 4.2.0)
#>  htmltools     0.5.2      2021-08-25 [1] CRAN (R 4.2.0)
#>  jquerylib     0.1.4      2021-04-26 [1] RSPM (R 4.1.0)
#>  jsonlite      1.8.0      2022-02-22 [2] CRAN (R 4.2.0)
#>  knitr         1.38       2022-03-25 [2] CRAN (R 4.2.0)
#>  lifecycle     1.0.1      2021-09-24 [2] CRAN (R 4.2.0)
#>  lubridate     1.8.0      2021-10-07 [1] CRAN (R 4.2.0)
#>  magrittr    * 2.0.2      2022-01-26 [2] CRAN (R 4.2.0)
#>  memoise       2.0.1      2021-11-26 [2] CRAN (R 4.2.0)
#>  pillar        1.7.0      2022-02-01 [2] CRAN (R 4.2.0)
#>  pkgconfig     2.0.3      2019-09-22 [2] CRAN (R 4.2.0)
#>  pkgdown       2.0.2.9000 2022-03-26 [1] Github (r-lib/pkgdown@98d5a5c)
#>  purrr         0.3.4      2020-04-17 [2] CRAN (R 4.2.0)
#>  R6            2.5.1      2021-08-19 [2] CRAN (R 4.2.0)
#>  ragg          1.2.2      2022-02-21 [1] CRAN (R 4.2.0)
#>  rlang         1.0.2      2022-03-04 [2] CRAN (R 4.2.0)
#>  rmarkdown     2.13       2022-03-10 [1] CRAN (R 4.2.0)
#>  rprojroot     2.0.2      2020-11-15 [2] CRAN (R 4.2.0)
#>  sass          0.4.1      2022-03-23 [1] CRAN (R 4.2.0)
#>  sessioninfo * 1.2.2      2021-12-06 [2] CRAN (R 4.2.0)
#>  stringi       1.7.6      2021-11-29 [2] CRAN (R 4.2.0)
#>  stringr       1.4.0      2019-02-10 [2] CRAN (R 4.2.0)
#>  systemfonts   1.0.4      2022-02-11 [1] CRAN (R 4.2.0)
#>  textshaping   0.3.6      2021-10-13 [1] CRAN (R 4.2.0)
#>  tibble        3.1.6      2021-11-07 [2] CRAN (R 4.2.0)
#>  tidyr         1.2.0      2022-02-01 [2] CRAN (R 4.2.0)
#>  tidyselect    1.1.2      2022-02-21 [2] CRAN (R 4.2.0)
#>  utf8          1.2.2      2021-07-24 [2] CRAN (R 4.2.0)
#>  vctrs         0.3.8      2021-04-29 [2] CRAN (R 4.2.0)
#>  xfun          0.30       2022-03-02 [2] CRAN (R 4.2.0)
#>  yaml          2.3.5      2022-02-21 [2] CRAN (R 4.2.0)
#> 
#>  [1] /__w/_temp/Library
#>  [2] /usr/local/lib/R/site-library
#>  [3] /usr/local/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────