Running R Analysis in Existing Projects
This skill operates inside an already structured R project. It helps extend, debug, or enhance existing analyses without recreating the project from scratch.
Use this skill when the user wants to:
- - Continue analysis in an existing R project
- Modify or extend R scripts
- Add new statistical models or tests
- Update plots or figures
- Regenerate reports after data or code changes
- Debug R errors in a project
What This Skill Does
When activated, this skill will:
- 1. Understand the project structure
- Detect folders like
data/,
scripts/,
results/,
reports/
- Identify
.Rproj,
.Rmd,
.qmd, or
.R files
- 2. Inspect existing analysis
- Read current scripts and reports
- Identify which packages and methods are being used
- Avoid rewriting working components unnecessarily
- 3. Extend or modify analysis
- Add new models or statistical tests
- Introduce new plots using
ggplot2
- Add new data processing steps
- Improve code structure or reproducibility
- 4. Re-run and update outputs
- Recompute results
- Overwrite or version new outputs in
results/
- Re-render R Markdown or Quarto reports
- 5. Debug issues
- Fix missing packages
- Resolve file path problems
- Handle common R errors and warnings
Example User Requests That Should Trigger This Skill
- - "Add a survival analysis to this R project"
- "Update the plots in my report"
- "This R Markdown file throws an error, fix it"
- "Extend this analysis with a mixed-effects model"
- "Re-run everything after I updated the data"
Example Workflow
User: Add a logistic regression model and update the report.
Skill actions:
- - Locate main analysis script
- Add logistic regression using INLINECODE10
- Save model summary to INLINECODE11
- Update report with new section and plot
- Re-render HTML/PDF report
Tools & Packages Commonly Used
| Purpose | R Packages |
|---|
| Data wrangling | tidyverse, dplyr |
| Modeling |
stats, lme4, glmnet |
| Visualization | ggplot2 |
| Reporting | rmarkdown, quarto |
| Project management | here, renv |
Notes
- - Respect the existing project structure and style
- Do not delete user code unless explicitly requested
- Prefer incremental updates over full rewrites
- Always regenerate reports after modifying analysis
在现有项目中运行R分析
此技能适用于已有结构的R项目。它帮助扩展现有分析、调试或增强功能,而无需从头重建项目。
当用户想要以下操作时使用此技能:
- - 在现有R项目中继续分析
- 修改或扩展R脚本
- 添加新的统计模型或检验
- 更新图表或图形
- 在数据或代码更改后重新生成报告
- 调试项目中的R错误
此技能的功能
激活后,此技能将:
- 1. 理解项目结构
- 检测如 data/、scripts/、results/、reports/ 等文件夹
- 识别 .Rproj、.Rmd、.qmd 或 .R 文件
- 2. 检查现有分析
- 读取当前脚本和报告
- 识别正在使用的包和方法
- 避免不必要地重写可用的组件
- 3. 扩展或修改分析
- 添加新模型或统计检验
- 使用 ggplot2 引入新图表
- 添加新的数据处理步骤
- 改进代码结构或可重复性
- 4. 重新运行并更新输出
- 重新计算结果
- 覆盖或版本化 results/ 中的新输出
- 重新渲染R Markdown或Quarto报告
- 5. 调试问题
- 修复缺失的包
- 解决文件路径问题
- 处理常见的R错误和警告
应触发此技能的用户请求示例
- - 向此R项目添加生存分析
- 更新我报告中的图表
- 此R Markdown文件报错,请修复
- 用混合效应模型扩展此分析
- 在我更新数据后重新运行所有内容
示例工作流程
用户: 添加逻辑回归模型并更新报告。
技能操作:
- - 定位主分析脚本
- 使用 glm() 添加逻辑回归
- 将模型摘要保存到 results/
- 用新章节和图表更新报告
- 重新渲染HTML/PDF报告
常用工具与包
| 用途 | R包 |
|---|
| 数据处理 | tidyverse, dplyr |
| 建模 |
stats, lme4, glmnet |
| 可视化 | ggplot2 |
| 报告生成 | rmarkdown, quarto |
| 项目管理 | here, renv |
注意事项
- - 尊重现有项目结构和风格
- 除非明确要求,否则不删除用户代码
- 优先进行增量更新而非完全重写
- 修改分析后始终重新生成报告