
R Visuals
R visual creation and ggplot2 patterns for PBIR reports.
Install
npx skills add data-goblin/power-bi-agentic-development --skill r-visuals -g -a claude-code -y- Repository
- data-goblin/power-bi-agentic-development1.1k
- Category
- Writing
- Updated
- 5d ago
- License
- GPL-3.0
- Context cost
- Mediumabout 2,220 tokens
- Runs scripts
- No, instructions only
What it does
R visual creation and ggplot2 patterns for PBIR reports. Automatically invoke when the user mentions "R visual", "ggplot2", "ggplot in Power BI", or asks to "create an R visual", "add an R chart", "write an R visual script", "inject an R script into Power BI".
R Visuals in Power BI (PBIR)
Use
pbirfor every report mutation. Read PBIR metadata only for diagnosis. Ifpbiris unavailable or lacks an operation, stop and report the gap; never edit report JSON directly.
R visuals execute R scripts (primarily ggplot2) to render static PNG images on the Power BI canvas. ggplot2 is the preferred library -- its grammar of graphics approach produces clean, publication-quality statistical visualizations with less code. R is particularly strong for statistical visualizations.
Visual Identity
- visualType:
scriptVisual - Data role:
Values(columns and measures, multiple allowed) - Data variable:
dataset(data.frame, auto-injected) - Row limit: 150,000 rows
- Output: Static PNG at 72 DPI -- no interactivity
Workflow: Creating an R Visual
Step 1: Add the Visual
pbir add visual scriptVisual "Report.Report/Page.Page" --name RevenueByDateR \
--data "Values:Sales.Date" --data "Values:Sales.Revenue"
Step 2: Write the Script
library(ggplot2)
p <- ggplot(dataset, aes(x=Date, y=Sales)) +
geom_col(fill="#5B8DBE") +
theme_minimal(base_size=12) +
theme(panel.grid.major.x=element_blank())
print(p) # MANDATORY for ggplot2
Critical rules:
print(p)is mandatory for ggplot2 objects -- they do not auto-display in Power BIdatasetis auto-injected as a data.frame; do not create it- Access columns by index (
dataset[,1]) to avoid name escaping issues - Use backticks for column names with spaces:
dataset$`Order Lines`
Step 2b: Review
Before presenting the script to the user, dispatch the r-reviewer agent to validate correctness and provide design feedback.
Step 3: Inject the Script
pbir visuals r "Report.Report/Page.Page/RevenueByDateR.Visual" --script-file chart.r
The CLI handles PBIR string escaping.
