rlang-patterns

Explain rlang metaprogramming patterns for data-masking and expression injection in R.

Updated Feb 24, 2026
One-click install
npx skills add https://github.com/jhelvy/dotfiles --skill rlang-patterns-jhelvy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rlang-patterns
Source: https://github.com/jhelvy/dotfiles/tree/main/claude/skills/rlang-patterns
Command: npx skills add https://github.com/jhelvy/dotfiles --skill rlang-patterns-jhelvy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps R programmers understand and implement advanced metaprogramming techniques using the rlang package, enabling them to write more robust, flexible, and powerful functions, especially those involving tidy evaluation and data-masking.

Core Features & Use Cases

  • Data-Masking: Learn how to use {{}}, .data, and .env for seamless column referencing in functions.
  • Expression Injection: Master !! and !!! for programmatically injecting expressions and arguments.
  • Dynamic Dots: Understand how to handle ... dynamically with name injection and splicing.
  • Use Case: When developing R packages or complex data analysis pipelines that need to accept user-defined column names or expressions, this Skill provides the patterns to do so safely and effectively.

Quick Start

Use the rlang-patterns skill to learn how to forward function arguments using the embracing {{}} operator.

Frequently Asked Questions about rlang-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use tidy evaluation to pass column names to a custom R function?

Tidy evaluation allows you to pass column names by using the embracing operator {{ }} inside your R function to forward arguments seamlessly. This enables robust data-masking for user-defined expressions in tidyverse-compatible pipelines.

What is the difference between !! and !!! for expression injection in rlang?

Expression injection with !! injects a single expression or object, while !!! splices a list of arguments into a function call. These rlang operators allow you to programmatically build and modify R code structures dynamically.

How do I handle dynamic dots (...) in R programming for dynamic argument splicing?

Dynamic dots are handled using rlang to capture, inject names, and splice arguments passed through .... This allows flexible argument forwarding and dynamic expansion of inputs within complex data analysis pipelines.

When should I use .data and .env pronouns for disambiguation in data-masking functions?

Use .data and .env pronouns when your data-masking function risks variable name collisions. They explicitly disambiguate whether an expression should be evaluated from the data frame or the surrounding environment.

Do I need rlang metaprogramming patterns to build tidyverse-compatible R packages?

You need rlang metaprogramming patterns when developing R packages that accept user-defined column names or expressions. These patterns ensure your functions interact safely and effectively with the tidyverse framework.

Why does my custom R function fail to evaluate a column name passed as a string?

This failure occurs because data-masking functions expect expressions or symbols, not strings. You must use rlang metaprogramming patterns like the embracing operator {{ }} or convert strings to symbols for proper evaluation.