Atlas / Skills / brycewang-stanford / R Reproducibility Guide

R Reproducibility GuideSAFE

skills/brycewang-stanford/r-reproducibility-guide

🔬 A curated collection of 23,000+ agent skills for empirical research across 8 social science disciplines. | 精选 23,000+ AI Agent 技能库,覆盖8大社会科学学科的实证研究。CoPaper.AI 20分钟完成一篇可复现的规范实证论文,并支持用户上传 Skills。-- Maintained by CoPaper.AI from Stanford REAP.

Verdict
SAFE
Grade
B
Trust score
89 /100
Version
—
Hosts
1 documented
License
NOASSERTION
Stars
4,537
01

Overview

🔬 A curated collection of 23,000+ agent skills for empirical research across 8 social science disciplines. | 精选 23,000+ AI Agent 技能库,覆盖8大社会科学学科的实证研究。CoPaper.AI 20分钟完成一篇可复现的规范实证论文,并支持用户上传 Skills。-- Maintained by CoPaper.AI from Stanford REAP.

Read from source at commit e1ba289846fdOBSERVED · 2026-10-08
02

Host compatibility

What the documentation claims. We have not run a compatibility test.

HostStatusNotes
openclawmentioned
03

What it tells the agent

The instruction file, verbatim from the audited commit — this is the text the model reads, and the surface the audit's instruction layer examines. Quoted here so you can judge it without cloning anything.

---
name: r-reproducibility-guide
description: "Create reproducible research workflows with R and RMarkdown/Quarto"
metadata:
  openclaw:
    emoji: "🔁"
    category: "tools"
    subcategory: "code-exec"
    keywords: ["R programming", "RMarkdown", "reproducibility", "Quarto", "renv", "computational reproducibility"]
    source: "wentor-research-plugins"
---

# Reproducible Research with R

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.

## Project Organization

### Recommended Directory Structure

```
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
```

### Key Principles

```
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)
```

## RMarkdown and Quarto

### RMarkdown Document

````markdown
---
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")
```
````

### Quarto (Next Generation)

```yaml
---
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.

## Package Management with renv

### Setting Up renv

```r
# 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()
```

### How renv Works

```python
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"
        ]
    }
```

## Automated Reporting

### Make-Based Pipeline

```makefile
# 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 Package (R-native Pipeline)

```r
# _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.

## Sharing Reproducible Analyses

### Options for Sharing

| 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
04

Trust audit

SAFEgrade B · trust 89/100 Nothing in the source contradicts what it says it does. Grade A is reserved for packages that have also passed the behavioural sandbox.

LayerWhat it checksResult
L0Provenance & inventoryPASS
L1Static analysis of the codeNA
L2Instruction surface (what it tells the agent)PASS
L3Class-specific surfacePASS
L4Behavioural (sandbox)SKIPPED

What the source does

Filesystem
none-observed
Network
none-observed
Shell
none-observed
Dependencies
pinned
Secrets in source
none-found

Findings (0)

No findings outside the package's declared scope.

Gates applied: no_behavioural_pass.

Audited 2026-10-08 · audit v0.4.1 · source sha e1ba289846fdfull audit observations/trust-audit/skill/brycewang-stanford__r-reproducibility-guide.json · Report an issue / request a re-scan
05

Audit history

Every audit this skill has had.

DateSourceVerdictGradeScoreChange
2026-10-08e1ba289846fdSAFEB89first audit
06

Questions

What does the R Reproducibility Guide skill do?

🔬 A curated collection of 23,000+ agent skills for empirical research across 8 social science disciplines. | 精选 23,000+ AI Agent 技能库,覆盖8大社会科学学科的实证研究。CoPaper.AI 20分钟完成一篇可复现的规范实证论文,并支持用户上传 Skills。-- Maintained by CoPaper.AI from Stanford REAP.

Is R Reproducibility Guide safe to install?

The audit found nothing in the source that contradicts what it says it does, and graded it B (89/100). Grade A is held back for packages that have also passed a sandboxed behavioural run, which is why a clean skill reads B.

What can R Reproducibility Guide access on my machine?

The audit observed no filesystem, network or shell use at all in its source.

Which assistants does R Reproducibility Guide work with?

Its documentation mentions openclaw. That is what the text claims, not a compatibility test we ran.

How current is this page?

The grade is for one exact copy of the source (e1ba289846fd), read on 2026-10-08. The repository is watched, and a new audit runs when it changes — this is the first audit.

Advertisement