skills/43-wentorai-research-plugins/skills/tools/code-exec/r-reproducibility-guide/SKILL.md
Create reproducible research workflows with R and RMarkdown/Quarto
npx skillsauth add brycewang-stanford/Awesome-Agent-Skills-for-Empirical-Research r-reproducibility-guideInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
A skill for creating fully reproducible research workflows in R using RMarkdown, Quarto, package management with renv, and project organization best practices. Covers literate programming, environment management, automated reporting, and sharing reproducible analyses.
my-research-project/
README.md
my-project.Rproj # RStudio project file
renv.lock # Package versions (managed by renv)
renv/ # renv library directory
data/
raw/ # Untouched original data
processed/ # Cleaned, analysis-ready data
R/
01-clean.R # Data cleaning functions
02-analyze.R # Analysis functions
03-visualize.R # Plotting functions
utils.R # Helper functions
analysis/
main-analysis.Rmd # Primary analysis notebook
supplementary.Rmd # Supplementary analyses
output/
figures/ # Generated plots
tables/ # Generated tables
manuscript.pdf # Compiled document
Makefile # Reproducible build commands
1. Raw data is read-only (never modify original data files)
2. All processing steps are scripted (no manual spreadsheet edits)
3. Generated outputs can be deleted and recreated from source
4. Package versions are locked with renv
5. Random seeds are set for all stochastic operations
6. Paths are relative to project root (never absolute)
---
title: "Analysis of Treatment Effects"
author: "Jane Smith"
date: "`r Sys.Date()`"
output:
pdf_document:
toc: true
number_sections: true
html_document:
toc: true
code_folding: hide
bibliography: references.bib
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
echo = TRUE,
message = FALSE,
warning = FALSE,
fig.width = 7,
fig.height = 5,
dpi = 300
)
library(tidyverse)
library(broom)
set.seed(42)
```
# Introduction
This analysis examines the effect of treatment on outcomes
[@smith2024].
# Methods
```{r load-data}
df <- read_csv("data/processed/study_data.csv")
glimpse(df)
```
# Results
```{r model}
model <- lm(outcome ~ treatment + age + gender, data = df)
tidy(model, conf.int = TRUE)
```
```{r fig-main, fig.cap="Treatment effect on primary outcome."}
ggplot(df, aes(x = treatment, y = outcome, fill = treatment)) +
geom_boxplot() +
theme_minimal() +
labs(x = "Group", y = "Outcome Score")
```
---
title: "Analysis Report"
format:
html:
code-fold: true
toc: true
pdf:
documentclass: article
execute:
echo: true
warning: false
---
Quarto supports R, Python, Julia, and Observable JS in a single document, making it ideal for multilingual research workflows.
# Initialize renv in your project
renv::init()
# Install packages as usual
install.packages("tidyverse")
install.packages("lme4")
# Snapshot current package versions
renv::snapshot()
# Restore environment from lockfile (on a new machine)
renv::restore()
def explain_renv() -> dict:
"""
Explain the renv reproducibility workflow.
"""
return {
"init": "Creates project-local library and renv.lock",
"snapshot": (
"Records exact package versions (name, version, source) "
"into renv.lock. Commit this file to Git."
),
"restore": (
"Installs exact package versions from renv.lock on any machine. "
"Collaborators run renv::restore() to match your environment."
),
"benefits": [
"Each project has isolated package versions",
"No conflicts between projects",
"Exact reproducibility months or years later",
"renv.lock is a text file that diffs cleanly in Git"
]
}
# Makefile for reproducible analysis
all: output/manuscript.pdf
data/processed/clean_data.csv: data/raw/study_data.csv R/01-clean.R
Rscript R/01-clean.R
output/figures/figure1.pdf: data/processed/clean_data.csv R/03-visualize.R
Rscript R/03-visualize.R
output/manuscript.pdf: analysis/main-analysis.Rmd data/processed/clean_data.csv
Rscript -e "rmarkdown::render('analysis/main-analysis.Rmd', output_dir='output')"
clean:
rm -rf output/figures/* output/manuscript.pdf data/processed/*
# _targets.R
library(targets)
tar_option_set(packages = c("tidyverse", "broom"))
list(
tar_target(raw_data, read_csv("data/raw/study_data.csv")),
tar_target(clean_data, clean_dataset(raw_data)),
tar_target(model, fit_model(clean_data)),
tar_target(report, {
rmarkdown::render("analysis/main-analysis.Rmd")
"output/manuscript.pdf"
})
)
The targets package tracks dependencies between pipeline steps and only reruns steps whose inputs have changed, saving time on large analyses.
| Method | Effort | Reproducibility | |--------|--------|----------------| | GitHub repo + renv.lock | Low | Good (requires R installation) | | Docker container | Medium | Excellent (full environment) | | Binder (mybinder.org) | Low | Good (browser-based, no install) | | Code Ocean capsule | Medium | Excellent (certified reproducibility) |
Always include a README with instructions for reproducing the analysis: required software, how to install dependencies (renv::restore), how to run the pipeline (make all), and expected runtime.
development
Conduct rigorous thematic analysis (TA) of qualitative data following Braun and Clarke's (2006) six-phase framework. Use whenever the user mentions 'thematic analysis', 'TA', 'Braun and Clarke', 'qualitative coding', 'identifying themes', or asks for help analysing interviews, focus groups, open-ended survey responses, or transcripts to identify patterns. Also trigger for questions about inductive vs theoretical coding, semantic vs latent themes, essentialist vs constructionist epistemology, building a thematic map, or writing up a qualitative findings section. Covers all six phases, the four upfront analytic decisions, the 15-point quality checklist, and the five common pitfalls. Produces a Word document write-up and an annotated thematic map. Does NOT cover IPA, grounded theory, discourse analysis, conversation analysis, or narrative analysis — use a different method for those.
development
Guide users through writing a systematic literature review (SLR) following the PRISMA 2020 framework. Use this skill whenever the user mentions 'systematic review', 'systematic literature review', 'SLR', 'PRISMA', 'PRISMA 2020', 'PRISMA flow diagram', 'PRISMA checklist', or asks for help writing, structuring, or auditing a literature review that follows reporting guidelines. Also trigger when the user asks about inclusion/exclusion criteria for a review, search strategies for databases like Scopus/WoS/PubMed, study selection processes, risk of bias assessment, or narrative synthesis for a review paper. This skill covers the full PRISMA 2020 checklist (27 items), produces a Word document manuscript in strict journal article format, generates an annotated PRISMA flow diagram, and enforces APA 7th Edition referencing throughout. It does NOT cover meta-analysis or statistical pooling. By Chuah Kee Man.
testing
Performs placebo-in-time sensitivity analysis with hierarchical null model and optional Bayesian assurance. Use when checking model robustness, verifying lack of pre-intervention effects, or estimating study power.
data-ai
Fit, summarize, plot, and interpret a chosen CausalPy experiment. Use after the causal method has been selected, including when configuring PyMC/sklearn models and scale-aware custom priors.