Standard operating procedure for research experiments, data analysis, and visualization. Covers Python/R script execution, statistical analysis, data wrangling (pandas/tidyverse), publication-quality figures (matplotlib/plotly/ggplot2), and experiment reproducibility.
workspace_save to outputs/scripts/; include docstring (hypothesis,
expected outcome, dependencies)exec in workspace (safe commands — see §5); capture stdout + stderroutputs/reports/Every script must include: shebang, docstring (experiment title, hypothesis, dependencies, date), seed setting (see §6), and four sections: loading, processing, analysis, output.
df.info(), df.describe(), df.head() — check dtypes, nulls, duplicatesworkspace_save("sources/data/<name>_clean.csv")Python: pandas/polars (DataFrames), numpy (numerics), dask (large files), spaCy (text). R: dplyr/tidyr (wrangling), data.table/arrow (large files), stringr/tidytext (text).
Browse analysis/wrangling/ for 10 deep-dive skills (pandas, missing data, survey, text mining).
What is your research question?
│
├── Comparing groups?
│ ├── 2 groups
│ │ ├── Continuous DV, normal → Independent t-test
│ │ ├── Continuous DV, non-normal → Mann-Whitney U
│ │ ├── Paired/matched → Paired t-test / Wilcoxon signed-rank
│ │ └── Categorical DV → Chi-square / Fisher's exact
│ ├── 3+ groups
│ │ ├── 1 factor, normal → One-way ANOVA → post-hoc (Tukey/Bonferroni)
│ │ ├── 1 factor, non-normal → Kruskal-Wallis → post-hoc (Dunn)
│ │ ├── 2+ factors → Two-way / N-way ANOVA (check interactions)
│ │ └── Repeated measures → Repeated-measures ANOVA / Friedman
│ └── Pre/post with control → Mixed ANOVA / DiD
│
├── Predicting an outcome?
│ ├── Continuous outcome → Linear regression (OLS)
│ │ ├── Multiple predictors → Multiple regression
│ │ ├── Non-linear → Polynomial / GAM / splines
│ │ └── Endogeneity → IV / 2SLS (see econometrics skills)
│ ├── Binary outcome → Logistic regression
│ ├── Count/ordinal → Poisson / Ordinal logistic
│ ├── Time-to-event → Cox proportional hazards
│ └── Panel data → Fixed/random effects (see econometrics skills)
│
├── Exploring relationships?
│ ├── 2 continuous vars → Pearson r (normal) / Spearman rho (non-normal)
│ ├── 2 categorical vars → Chi-square test of independence
│ ├── Latent constructs → Factor analysis / SEM
│ └── Dimensionality → PCA / t-SNE
│
└── Estimating causal effects?
├── Randomized experiment → t-test / ANOVA with random assignment
├── Natural experiment → DiD, RDD, IV
└── Observational → Propensity score matching, synthetic control
Every test must report: test name, statistic value (t/F/chi-sq/U/z), df, exact p-value, effect size (Cohen's d / eta-sq / Cramer's V / OR), 95% CI, assumptions checked (normality, homoscedasticity, independence), sample size per group.
Deep-dive skills: browse analysis/statistics/ (10 skills: Bayesian, meta-analysis,
SEM, survival, power analysis, nonparametric) and analysis/econometrics/ (12 skills:
causal inference, panel data, IV, time series).
| Data pattern | Chart type |
|---|---|
| Distribution (1 var) | Histogram, KDE, box/violin plot |
| Comparison (categories) | Bar chart, grouped bar, dot plot |
| Trend over time | Line chart, area chart |
| Relationship (2 vars) | Scatter plot, regression plot |
| Correlation matrix | Heatmap |
| Composition | Stacked bar, treemap |
| Geographic | Choropleth, point map |
| Network / graph | Force-directed, adjacency matrix |
| High-dimensional | PCA biplot, t-SNE, UMAP |
Set plt.rcParams for journal figures: figure.dpi: 300, font.family: serif,
font.size: 10, savefig.bbox: tight. Key rules:
workspace_save("outputs/figures/fig-<desc>.pdf", content)Deep-dive skills: browse analysis/dataviz/ (14 skills: matplotlib, plotly, D3,
publication figures, color accessibility, geospatial, network viz).
Safe (no approval): python3, Rscript, xelatex, pandoc, jq, wc, grep, find.
Requires approval_card: pip install, brew install, curl, wget, anything outside workspace.
Full safety rules in Workspace SOP.
Common patterns:
exec("python3 outputs/scripts/experiment.py") — run analysisexec("Rscript outputs/scripts/analysis.R") — R scriptexec("python3 -c \"import pandas; ...\"") — quick inspectionOutput paths: All script outputs (figures, data, reports) MUST use
workspace-relative paths. Set the working directory to workspace root before
execution, and use paths like outputs/figures/, outputs/reports/.
Template for Python:
import os
os.chdir(os.environ.get('WORKSPACE_ROOT', '.'))
At analysis start, capture Python version, platform, and key package versions
(numpy, pandas, scipy, matplotlib, sklearn). Save via
workspace_save("outputs/reports/env-snapshot-<date>.json").
Before writing code, assess complexity:
Simple task (single file, stdlib only, no iteration)
→ RC handles directly via exec
Complex task (multi-file, dependencies, iterative debugging)
→ Check MEMORY.md Environment for installed CLIs (codex, claude, opencode)
→ CLI found → inform user, suggest delegating via exec
→ User agrees → exec the CLI (read claude-code / codex-cli / opencode-cli skill)
→ User wants RC → proceed with RC's own capabilities
→ No CLI → recommend installation, wait for user decision
→ User insists → RC proceeds via repeated workspace_save + exec (slower)
Boundary: "complex coding" = multi-file projects, dependency management, iterative debugging, beamer/multi-chapter LaTeX, interactive visualizations. For these, the Claude Code, Codex CLI, and OpenCode CLI skills provide delegation guidance.
outputs/scripts/ (or outputs/notebooks/),
figures to outputs/figures/, processed data to sources/data/.
Commit message prefix: Add: / Update:.workspace_save again, re-run.For detailed methodology beyond this SOP, browse these RP skill indexes:
| Index path | Skills | Covers |
|---|---|---|
tools/code-exec/ | 7 | Jupyter, Colab, Kaggle, reproducibility (Python/R) |
analysis/statistics/ | 10 | Hypothesis testing, Bayesian, meta-analysis, SEM, survival |
analysis/econometrics/ | 12 | Causal inference, panel data, IV, DiD, time series, Stata |
analysis/wrangling/ | 10 | pandas, data cleaning, missing data, survey, text mining |
analysis/dataviz/ | 14 | matplotlib, plotly, D3, publication figures, geospatial, networks |
domains/ai-ml/ | 27 | PyTorch, TensorFlow, LLM eval, experiment tracking, ML pipelines |
tools/diagram/ | 9 | Mermaid, PlantUML, GraphViz, flowcharts, scientific diagrams |
domains/ | 147 | 16 disciplines — browse domains/{field}/ for domain-specific analysis methods |