r-rlang-programming

Apply rlang metaprogramming for tidy evaluation and data-masked APIs in R.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/jjjermiah/dot-agents --skill r-rlang-programming
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: r-rlang-programming
Source: https://github.com/jjjermiah/dot-agents/tree/main/src/dot-agents/skills/r-rlang-programming
Command: npx skills add https://github.com/jjjermiah/dot-agents --skill r-rlang-programming

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Metaprogramming in R often requires composing code as data, managing tidy evaluation, and controlling evaluation environments. This skill provides a structured guide to build reliable, data-masked APIs with rlang.

Core Features & Use Cases

  • Embrace and inject patterns using {{, !!, !!! to enable data-masked APIs and dynamic code construction.
  • Tidy evaluation, symbols and calls, and environment hygiene for robust package development and DSLs.
  • Structured error handling with abort()/warn() and clear guidance for testing and debugging metaprogramming workflows.
  • Examples and patterns for wrapping dplyr/ggplot2 workflows, building programmatic APIs, and safe evaluation contexts.

Quick Start

Practice by creating a small function that uses {{ var }} to accept a column name and apply a dplyr verb.

Frequently Asked Questions about r-rlang-programming

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

FAQPage Schema
How do I use tidy evaluation to pass column names dynamically to dplyr verbs?

Tidy evaluation lets you pass column names dynamically using the embrace pattern {{ var }} to defuse and inject expressions into data-masked APIs like dplyr verbs. This ensures your custom functions correctly evaluate variables within the data frame context.

What is the difference between !! and !!! when injecting objects into rlang expressions?

The !! operator injects a single defused object into an expression, while !!! splices a list of objects into a function call. Both are core rlang metaprogramming tools for building programmatic interfaces and dynamic code construction in R.

How do I handle environments correctly when building data-masked APIs in R?

Handling environments in data-masked APIs requires managing evaluation context explicitly to maintain environment hygiene. rlang provides tools to defuse expressions and control where code evaluates, preventing scope leaks and ensuring robust package development.

How do I create structured errors in R packages using rlang abort?

rlang's abort() function creates structured errors with custom metadata, allowing you to enforce clear guidance for testing and debugging metaprogramming workflows. It helps provide precise error messaging when data masking or expression injection fails.

Can I use rlang metaprogramming to wrap ggplot2 workflows programmatically?

Yes, rlang metaprogramming supports wrapping ggplot2 workflows by defusing aesthetic mappings and injecting them dynamically. You can build programmatic interfaces that construct ggplot2 layers dynamically using tidy evaluation patterns.

Why does my custom tidy eval function fail to find objects in the correct environment?

Custom tidy eval functions fail when evaluation context is not properly managed, causing scope leaks. Using rlang's defusal and injection patterns correctly ensures expressions evaluate in the intended data mask and environment.