DAAF-Contribution-Community/daaf / .claude/skills/python-r-translation
python-r-translation
VerifiedPython-to-R translation for data analysis. Maps Python (polars, plotnine, pyfixest, statsmodels, svy, geopandas) to R (tidyverse, ggplot2, fixest, survey, sf). Use when user has Python background or requests Python-equivalent code comments in R pipelines.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 22.6 KB |
| references/causal-inference.md | markdown | 6.2 KB |
| references/dplyr-polars.md | markdown | 11.4 KB |
| references/external-resources.md | markdown | 7.2 KB |
| references/gotchas.md | markdown | 9.8 KB |
| references/paradigm-differences.md | markdown | 17.0 KB |
| references/regression-modeling.md | markdown | 9.4 KB |
| references/strings-dates-factors.md | markdown | 8.2 KB |
| references/survey-spatial-ml.md | markdown | 8.0 KB |
| references/visualization.md | markdown | 5.2 KB |
| references/workflow-environment.md | markdown | 6.0 KB |
references/external-resources.md
View on GitHub# External Resources for Python-to-R Translation
Curated catalog of resources for Python users transitioning to R in quantitative
social science contexts. Each entry includes provenance tracking, quality
assessment, and key takeaways.
Resources are assessed for currency, accuracy, and relevance to the DAAF R stack
(tidyverse, fixest, ggplot2, survey, sf). Entries marked with currency concerns
should be cross-checked against current documentation.
---
## Package-Specific Documentation
### fixest Documentation
- **Author(s):** Laurent Bergé
- **URL:** https://lrberge.github.io/fixest/
- **Type:** Documentation
- **Last verified:** 2026-03-28
- **Quality:** Excellent
- **Key content:** Complete documentation for R's premier fixed effects regression
package. Covers OLS, IV, Poisson, negative binomial with multi-way FE, clustered
SEs, etable, coefplot/iplot, Sun-Abraham DiD. Python users familiar with pyfixest
will find the API intentionally parallel.
- **For Python users:** The formula syntax is nearly identical to pyfixest. The
main differences are clustering syntax (`~entity` vs `{"CRV1": "entity"}`) and
that R fixest's `feglm()` covers more GLM families with FE (e.g., Gamma) plus
`fenegbin`; pyfixest's `feglm()` supports FE for logit/probit/gaussian since 0.50.
### ggplot2 Documentation
- **Author(s):** Hadley Wickham et al.
- **URL:** https://ggplot2.tidyverse.org/
- **Type:** Documentation
- **Last verified:** 2026-03-28
- **Quality:** Excellent
- **Key content:** Definitive reference for the grammar of graphics in R. plotnine
users will find the function reference organized identically. The main adjustment
is bare column names vs strings in `aes()`.
### dplyr Documentation
- **URL:** https://dplyr.tidyverse.org/
- **Type:** Documentation
- **Last verified:** 2026-03-28
- **Quality:** Excellent
- **For Python users:** Maps directly to polars operations. `mutate()` = `with_columns()`,
`filter()` = `filter()`, `select()` = `select()`, `summarise()` = `agg()`,
`left_join()` = `join(how="left")`.
### marginaleffects: Model to Meaning
- **Author(s):** Vincent Arel-Bundock (book; CRC Press, 2026); JSS article with Noah Greifer and Andrew Heiss (2024)
- **URL:** https://marginaleffects.com/
- **Type:** Documentation / Book
- **Last verified:** 2026-03-28
- **Quality:** Excellent
- **Key content:** Every page has an R/Python toggle showing equivalent code. The
gold standard for cross-language post-estimation analysis. Covers predictions,
comparisons, slopes, and hypothesis testing. Published in JSS (v111, i09).
### rdrobust: RD Packages
- **Author(s):** Calonico, Cattaneo, Farrell, Titiunik (CRAN; rdpackages project)
- **URL:** https://github.com/rdpackages/rdrobust
- **Type:** Documentation
- **Last verified:** 2026-03-28
- **Quality:** Excellent
- **Key content:** Unified documentation for R, Python, and Stata with identical
APIs and function names. The translation is nearly mechanical.
### survey Package Documentation
- **URL:** https://cran.r-project.org/package=survey
- **Type:** Documentation
- **Last verified:** 2026-03-28
- **For Python users:** R's `survey` covers substantially more model families than
`svy`. The formula interface (`~varname`) replaces string arguments.
### sf (r-spatial) Documentation
- **URL:** https://r-spatial.github.io/sf/
- **Type:** Documentation
- **Last verified:** 2026-03-28
- **For Python users:** `st_read()` = `gpd.read_file()`, `st_join()` = `gpd.sjoin()`,
`st_transform()` = `gdf.to_crs()`. R uses standalone `st_*()` functions where
Python uses GeoDataFrame methods.
---
## Textbooks with Dual-Language Code
### The Effect: An Introduction to Research Design and Causality
- **Author(s):** Nick Huntington-Klein
- **URL:** https://theeffectbook.net/
- **Quality:** Excellent
- **Key content:** Causal inference textbook with code in R, Stata, and Python.
The triple-language examples make this the best single resource for seeing how
the same method is implemented across ecosystems. Free online.
### Using R, Python, and Julia for Introductory Econometrics
- **Author(s):** Florian Heiss, Daniel Brunner
- **URL:** https://www.urfie.net/
- **Quality:** Good
- **Key content:** Parallel implementations of Wooldridge's econometrics examples.
Every example exists in R, Python, and Julia with identical expected results.
### R for Data Science (2nd Edition)
- **Author(s):** Hadley Wickham, Mine Çetinkaya-Rundel, Garrett Grolemund
- **URL:** https://r4ds.hadley.nz/
- **Quality:** Excellent
- **Key content:** The definitive tidyverse guide. Understanding dplyr patterns
here maps directly to polars translations. R-only but essential as the "target
language" reference.
### Causal Inference: The Mixtape
- **Author(s):** Scott Cunningham
- **URL:** https://mixtape-1ed.netlify.app/ (1st ed.; the 2nd ed., *The Remix*, is in progress at mixtape.scunning.com)
- **Quality:** Good
- **Key content:** Causal inference with R and Stata code in the print edition;
the online 1st edition also has Python code tabs. Accessible writing with
real-world examples. The Mixtape Sessions workshops (mixtapesessions.io) teach
with R and Stata.
---
## General Python-to-R Guides
### Coding for Economists: Coming from R
- **Author(s):** Arthur Turrell
- **URL:** https://aeturrell.github.io/coding-for-economists/coming-from-r.html
- **Quality:** Excellent
- **Key content:** While titled "Coming from R," the side-by-side comparisons work
equally well in reverse. Provides package equivalency tables and code comparisons
for common operations.
### Polars' Rgonomic Patterns
- **Author(s):** Emily Riederer
- **URL:** https://www.emilyriederer.com/post/py-rgo-polars/
- **Quality:** Excellent
- **Key content:** Deep analysis of how polars mirrors dplyr's ergonomic design.
Reading this in reverse helps Python users understand why dplyr feels natural
to R users and what design principles they share.
### Tidy Data Manipulation: dplyr vs polars
- **Author(s):** Christoph Scheuch
- **URL:** https://blog.tidy-intelligence.com/posts/dplyr-vs-polars/
- **Quality:** Good
- **Key content:** Systematic function-by-function comparison. Highlights that
dplyr allows referencing new columns in the same mutate block while polars
does not.
---
## R Package Documentation (Target Language References)
| R Package | URL | Python Equivalent |
|-----------|-----|------------------|
| dplyr | https://dplyr.tidyverse.org/ | polars |
| ggplot2 | https://ggplot2.tidyverse.org/ | plotnine |
| fixest | https://lrberge.github.io/fixest/ | pyfixest |
| survey | https://cran.r-project.org/package=survey | svy |
| sf | https://r-spatial.github.io/sf/ | geopandas |
| tidymodels | https://www.tidymodels.org/ | scikit-learn |
| Quarto | https://quarto.org/ | marimo |
| plm | https://cran.r-project.org/package=plm | linearmodels |
---
## Community Resources
| Resource | URL | Notes |
|----------|-----|-------|
| Stack Overflow `[r]` tag | https://stackoverflow.com/questions/tagged/r | Most R questions answered |
| RStudio Community | https://community.rstudio.com/ | Friendly, moderated |
| R-bloggers | https://www.r-bloggers.com/ | Aggregated R tutorials |
| #rstats on social media | Various | Active community |
| CRAN Task Views | https://cran.r-project.org/web/views/ | Package discovery by topic |
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |