19.2 Motivation

Simple concrete example:

Cement is a function that works like paste but doesn’t need need quotes:

cement <- function(...) {
  args <- ensyms(...)
  paste(purrr::map(args, as_string), collapse = " ")
}

cement(Good, morning, Hadley)
#> [1] "Good morning Hadley"

What if we wanted to use variables ? This is where ‘unquoting’ comes in!

name = "Bob"
cement(Good, afternoon, !!name)
#> [1] "Good afternoon Bob"