I set out reading this book hoping to understand the metaprogramming chapter, and ended up learning a bunch of other stuff along the way! Here’s a non-exhaustive list of things I learned from each of the sections of Advanced R:

I - Foundations:

II - Functional Programming

III - OOP

IV Metaprogramming

V Techniques

Toy Code

Metaprogramming - how to pass expressions into select statements. Also example of switch.

library(dplyr)
library(rlang)

grouping_variables <- switch(
  params$group_type,
  "S" = exprs(CraftCode, starts_with("Product"), ModelCode, Elevation),
  "B" = exprs(starts_with("Rate")),
  "P" = exprs(starts_with("Part"))
)
  
null_bids <- bids %>%
  group_by(SupplierID, ProjectID, !!!grouping_variables) %>%
  slice_max(LastModDate) %>%
  ungroup() %>%
  select(!!!grouping_variables, ProjectID, SupplierAID, SupplierName, UnitPrice) %>%
  left_join(lowest_bids, by = as.character(grouping_variables))