What is tidy evaluation, and what are quosures and quasiquotation in the rlang framework?

Quick Overview

Explain tidy evaluation in R and the rlang tools behind it: data masking, quosures, and quasiquotation with !!, !!! and the curly-curly operator. Tests whether you can write functions that wrap dplyr verbs, pass column names through correctly and avoid scoping and string-handling mistakes.

What is tidy evaluation, and what are quosures and quasiquotation in the rlang framework?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Other

What is tidy evaluation, and what are quosures and quasiquotation in the `rlang` framework? ```hint Start from the bare name In `filter(df, x > 1)`, R would normally evaluate `x` before `filter()` even runs. Think about what `filter()` has to do instead, and what it needs to remember about the expression. ``` ```hint Write a wrapper Try writing a function that takes a column and calls `group_by()` on it. Work out why the obvious version fails and what has to be passed through. ``` ### What a Strong Answer Covers - The problem tidy evaluation solves: data masking of bare column names - What a quosure stores and why its environment matters - How quasiquotation works with `!!`, `!!!` and the `{{ }}` shortcut - How to handle column names that arrive as strings and how to name output columns dynamically - Pitfalls such as a column and a variable sharing the same name ### Follow-up Questions - A wrapper function receives the column name as a string. How do you use it in `filter()` and in `select()`? - A data frame has a column with the same name as a variable in your function. Which one does `filter()` use, and how do you make the choice explicit? - What is the difference between `enquo()` and `ensym()`, and when would you use each?

Overview: Explain tidy evaluation in R and the rlang tools behind it: data masking, quosures, and quasiquotation with !!, !!! and the curly-curly operator. Tests whether you can write functions that wrap dplyr verbs, pass column names through correctly and avoid scoping and string-handling mistakes.

General logo
General
Nov 24, 2026
mediumData ScientistOtherData Manipulation (SQL/Python)
0
0

What is tidy evaluation, and what are quosures and quasiquotation in the rlang framework?

What a Strong Answer Covers Guidance

  • The problem tidy evaluation solves: data masking of bare column names
  • What a quosure stores and why its environment matters
  • How quasiquotation works with !! , !!! and the {{ }} shortcut
  • How to handle column names that arrive as strings and how to name output columns dynamically
  • Pitfalls such as a column and a variable sharing the same name

Follow-up Questions Guidance

  • A wrapper function receives the column name as a string. How do you use it in filter() and in select() ?
  • A data frame has a column with the same name as a variable in your function. Which one does filter() use, and how do you make the choice explicit?
  • What is the difference between enquo() and ensym() , and when would you use each?