How defusal/injection solve problem 2

Defuse

  • If bare column names are not defused, they will be evaluated immediately–hence in the wrong (global) environment
  • If those names are defused, they need to be marked for later evaluation
  • Mechanisms:
    • First quote (e.g., enquo) and evaluate (i.e., !!)
    • Embrace to quote and evaluate in one go for single columns: {{

Inject

  • If bare column names are provided as arguments, they must be “injected” into the function’s body
  • Mechanisms: same as above

Summary of how data masking works

  1. Defuse arguments. First, quote bare names. Then, evaluate them later.
  2. Make data an environment. Column names are resolved here.
  3. Evaluate arguments explicitly.