Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
ICYMI: RPweave — Unified R + Python + LaTeX Workflow (Powered by uv)
If you juggle R, Python, and LaTeX for research, you know the pain: fragmented scripts, mixed environments, manual copying, and fragile reproducibility.
I needed a setup/workflow that handles both languages, any LaTeX template, environment isolation, and a command-line–first workflow — so I assembled RPweave. Not a new idea, but a polished, modern take that just works.
RPweave (GitHub template here: https://github.com/Techtonique/RPweave) ties everything together using:
- knitr for R + Python chunks
- reticulate for seamless Python integration
- LaTeX for publication-ready typesetting
- uv for fast, reproducible Python environments
- Makefile automation for building and previewing
- A ready-to-clone Git template
Getting Started
The workflow starts by cloning the RPweave template repo, and listing the Python packages you need in requirements.txt. Then, set up the isolated environment and install R dependencies via make setup. Finally, write your .Rnw document mixing R and Python chunks, and build with make view.
git clone https://github.com/Techtonique/RPweave my-paper cd my-paper uv venv venv && source venv/bin/activate make setup make view
Why It Matters
RPweave lets you:
- Run R and Python in the same
.Rnwdocument at the command line - Easily share objects across languages
- Use any LaTeX template or academic style
- Keep everything reproducible with isolated environments
- Build your PDF with a single command (
make view)
Minimal Example
The first chunk is mandatory.
<<setup>>=
library(knitr); library(reticulate)
use_python("venv/bin/python")
@
<<r-analysis>>=
ggplot(mtcars, aes(wt, mpg)) + geom_point()
@
<<python-analysis, engine='python'>>=
import pandas as pd
print(pd.DataFrame({'x': range(100)}).describe())
@
Ideal For
- Papers mixing R stats + Python ML
- Projects needing clean LaTeX output
- Reproducible workflows with pinned dependencies
- Researchers tired of context-switching between RStudio, Jupyter, and LaTeX editors
Pro Tips
- Use
make viewas your main loop — instant rebuild + preview - Store long chunks in
chunks/ - Keep generated files out of Git
- Pass data R → Python via
py$objectfor smooth cross-language flows
Repo & Docs
- RPweave: https://github.com/Techtonique/RPweave
- uv: https://docs.astral.sh/uv/
- knitr: https://yihui.org/knitr/
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
