review-r
R code review for the sewage project. Checks script structure, reproducibility, function design, figure quality, and professional polish against pro…
它会碰到什么
扫了多少1 个文本文件,5 KB
它会碰到什么不碰外部(只输出文字)
命中总数0 处
命中统计严重 0 · 高 0 · 中 0 · 低 0
这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。
技能内容
Review R Code
Run a code quality review on R scripts in the sewage project. Produces a report — does NOT edit source files.
Input: $ARGUMENTS — a .R filename, directory path, or all.
Project-Specific Conventions
Script Structure
Pipeline scripts (layers 01-06):
Header block (########) → roxygen description → initialise_environment() → setup_logging() → CONFIG list → functions → main() → conditional execution (sys.nframe() == 0)
Analysis scripts (09_analysis):
Numbered sections with # === separators, inline package loading, direct execution (no main() wrapper)
Required Conventions
- Paths:
here::here()— never relative paths orsetwd() - Data formats:
arrow(parquet) for intermediate/final; DuckDB for large joins - Pipe: Native R pipe
|>(not%>%) - Naming:
snake_casefor functions/variables,UPPER_SNAKE_CASEfor constants - Econometrics:
fixest::feols()for regressions - Tables:
modelsummary→ LaTeX withtabularrayformat - SE:
vcov = "hetero"for heteroskedasticity-robust - Factors:
forcats::as_factor()/forcats::fct_drop()
Key Files
- Scripts:
scripts/R/01_data_ingestion/throughscripts/R/09_analysis/ - Utilities:
scripts/R/utils/ - Output:
output/{figures,tables,html_plots,regs,log}/
Workflow
Step 1: Identify Scripts
- If
$ARGUMENTSis a specific.Rfile: review that file - If
$ARGUMENTSis a directory: review all.Rfiles in that directory - If
$ARGUMENTSisall: review all scripts inscripts/R/ - If no argument: ask which scripts to review
Step 2: Review Each Script (9 Categories)
Category 1: Script Structure
- Pipeline scripts: header block, roxygen,
initialise_environment(),CONFIGlist,main(), conditional execution - Analysis scripts: numbered sections with
# ===separators - Clear separation of concerns
Category 2: Console Hygiene
- No unnecessary
print()/cat()pollution - Logging via
setup_logging()in pipeline scripts - Clean output — only meaningful messages
Category 3: Reproducibility
set.seed()where randomness is involved- All paths via
here::here()— nosetwd(), no relative paths, no hardcoded absolute paths - No hardcoded values that should be in CONFIG
Category 4: Function Design
- DRY — no duplicated code blocks
- Functions at appropriate abstraction level
- Shared utilities in
scripts/R/utils/where reuse is needed
Category 5: Figure Quality
- Axis labels present and readable
- Appropriate dimensions (not too wide/narrow)
- Consistent theme across plots
- Alpha transparency for overlapping points
- Saved to
output/figures/viahere::here()
Category 6: Data Persistence
- Intermediate results saved as parquet (
arrow::write_parquet()) saveRDS()for R-specific objects- No orphaned temporary files
Category 7: Comments
- Explain why, not what
- Section headers for navigation
- No commented-out dead code
Category 8: Error Handling
- Graceful failures with informative messages in pipeline scripts
- File existence checks before reading
- Data validation where appropriate
Category 9: Polish
- Consistent style (indentation, spacing)
- No dead code or unused imports
- Clean namespace —
library()calls at top - Native pipe
|>(not magrittr%>%)
Step 3: Present Summary
## Code Review: [filename/directory]
**Date:** YYYY-MM-DD
**Scripts reviewed:** N
### Issues by Severity
| Script | Critical | Major | Minor |
|--------|----------|-------|-------|
| ... | ... | ... | ... |
### Top 3 Critical Issues
1. ...
2. ...
3. ...
### Conventions Compliance
- [ ] here::here() for all paths
- [ ] Native pipe |>
- [ ] arrow/parquet for data
- [ ] fixest for regressions
- [ ] modelsummary for tables
### Score: XX / 100
Save report to output/log/code_review_[target].md.
Step 4: IMPORTANT
Do NOT edit any source files. Only produce reports. Fixes are applied after user review.
Principles
- Report only, never edit. The reviewer is a critic, not a creator.
- Project conventions matter. Flag deviations from the conventions above, not personal preferences.
- Proportional severity. A missing
set.seed()is Major. A missing comment is Minor. Usingsetwd()is Critical. - Language-specific. Check R idioms — vectorised operations over loops, tidyverse patterns, proper use of factors.
- Pipeline vs analysis distinction. Different structure expectations for pipeline scripts vs analysis scripts.
想直接用这个技能?
本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。
它属于哪个仓库
星标★ 3,829
本站分层T1
该仓技能数1161
原文件路径
skills/41-sticerd-eee-sewage-econometrics-check/skills/review-r/SKILL.md同一个仓库里的其他技能
- Full-empirical-analysis-skill
- Full-empirical-analysis-skill-R
- Full-empirical-analysis-skill-Stata
- auto-empirical-research-skills
- StatsPAI_skill
- Full-empirical-analysis-skill
- Full-empirical-analysis-skill-Stata
- Full-empirical-analysis-skill-R
- academic-paper-composer
- academic-paper-strategist
- medical-imaging-review
- paper-slide-deck
同名技能的其他版本
有 5 个不同仓库或目录里都有叫 review-r 的技能。它们内容并不相同,别混用:
- brycewang-stanford/Auto-Empirical-Research-Skills — Run the R code review protocol on R scripts. Checks code quality, reproducibility, domain
- brycewang-stanford/Auto-Empirical-Research-Skills — Run the R code review protocol on R scripts. Checks code quality, reproducibility, domain
- brycewang-stanford/Auto-Empirical-Research-Skills — >-
- brycewang-stanford/Auto-Empirical-Research-Skills — Run the R code review protocol on R scripts. Checks code quality, reproducibility, domain