| name | moai-lang-r |
| description | R 4.4+ development specialist covering tidyverse, ggplot2, Shiny, and data science patterns. Use when developing data analysis pipelines, visualizations, or Shiny applications.
|
| license | Apache-2.0 |
| compatibility | Designed for Claude Code |
| allowed-tools | Read Grep Glob Bash(R:*) Bash(Rscript:*) mcp__context7__resolve-library-id mcp__context7__get-library-docs |
| user-invocable | false |
| metadata | {"version":"1.1.0","category":"language","status":"active","updated":"2026-01-11","modularized":"true","tags":"language, r, tidyverse, ggplot2, shiny, dplyr, data-science"} |
| progressive_disclosure | {"enabled":true,"level1_tokens":100,"level2_tokens":5000} |
| triggers | {"keywords":["R","tidyverse","ggplot2","Shiny","dplyr","data science",".R",".Rmd",".qmd","DESCRIPTION","renv.lock"],"languages":["r"]} |
Quick Reference (30 seconds)
R 4.4+ Development Specialist - tidyverse, ggplot2, Shiny, renv, and modern R patterns.
Auto-Triggers: Files with .R extension, .Rmd, .qmd, DESCRIPTION, renv.lock, Shiny or ggplot2 discussions
Core Capabilities:
- R 4.4 Features: Native pipe operator, lambda syntax with backslash, improved error messages
- Data Manipulation: dplyr, tidyr, purrr, stringr, forcats
- Visualization: ggplot2, plotly, scales, patchwork
- Web Applications: Shiny, reactivity, modules, bslib
- Testing: testthat 3.0, snapshot testing, mocking
- Package Management: renv, pak, DESCRIPTION
- Reproducible Reports: R Markdown, Quarto
- Database: DBI, dbplyr, pool
Quick Patterns
dplyr Data Pipeline Pattern:
Load tidyverse library. Create result by piping data through filter for year 2020 or later, mutate adding revenue_k as revenue divided by 1000 and growth as current minus lagged revenue divided by lagged revenue, group_by category, then summarise with total_revenue as sum, avg_growth as mean with na.rm TRUE, and groups set to drop.
ggplot2 Visualization Pattern:
Load ggplot2 library. Create ggplot with data and aes mapping x to date, y to value, and color to category. Add geom_line with linewidth 1 and geom_point with size 2. Apply scale_color_viridis_d for color scale. Add labs for title, axis labels, and color legend. Apply theme_minimal for clean appearance.
Shiny Basic App Pattern:
Load shiny library. Create ui using fluidPage with selectInput for variable selection from mtcars column names and plotOutput for plot. Create server function with input, output, and session parameters. In server, assign renderPlot to output plot using ggplot with mtcars and aes using .data pronoun with input variable for histogram. Create app with shinyApp passing ui and server.
Implementation Guide (5 minutes)
R 4.4 Modern Features
Native Pipe Operator:
Create result by piping data through filter removing NA values, mutate adding log_value as log of value, and summarise computing mean_log. For non-first argument position, use underscore placeholder in lm formula call with data parameter.
Lambda Syntax with Backslash:
Use map with data and backslash x syntax for x squared. Use map2 with two lists and backslash x y for x plus y. In dplyr contexts, use mutate with across on numeric columns applying backslash x for scale function extracting first column.
tidyverse Data Manipulation
dplyr Core Verbs:
Load dplyr library. Create processed by piping raw_data through filter for active status and positive amount, select for specific columns, mutate adding month using floor_date and amount_scaled dividing by max, then arrange descending by date. For grouped summaries, pipe through group_by, summarise with n for count, sum and mean for aggregations, and groups drop.