r-for-analysis
Installation
SKILL.md
R for Analysis
Produce R analysis code that another analyst can re-run a year later and get the same answer. The costly mistake this prevents: interactive one-off scripts with silent type inference, implicit grouping, and unseeded randomness - code that works once on one laptop and never again.
Inputs to collect
Before writing code, establish:
- The data source and its shape - file, database, or in-memory; roughly how many rows (millions of rows change the tool choice: consider data.table or duckdb backends past ~10M rows).
- The analytical question in one sentence. If the user cannot state it, help them state it first - code without a question produces plots without a point.
- The output target - exploratory notebook, Quarto report, or a table/figure for a deck. This decides how much polish the code needs.
Label any assumption about column meanings as a guess and confirm against a glimpse() of the real data.
Operating procedure
Work in this order - each step protects the ones after it.