How can I convert a Rmd document to a jupyter notebook
sos-rmarkdown provides yet another Rmarkdown to Jupyter notebook converter. The unique features include its support for inline expressions using markdown-kernel, use of multiple kernels in one notebook (using a SoS kernel) to accommodate code blocks in multiple languages, and the ability to execute generated notebook using sos-papermill. It also uses cell meta data to control the display of input and output of code blocks in Jupyter Lab and exported HTML reports.
To use this tool, you can install sos-rmarkdown
from pip
or conda-forge
, then run the converter with command
sos convert input.Rmd output.ipynb
or use option --execute
to execute the converted notebook
sos convert input.Rmd output.ipynb --execute
Disclaimer: I am the author of sos-rmarkdown
.
After checking, the silver bullet seems to be jupytext
It allows you to convert from or to markdown
, rmarkdown
, python
, ipynb
, etc.
This can actually allow you a pretty neat workflow
- write a simple R script,
script.R
, that you can spin into aRmd
document - use
knitr::spin('script.R', knit = FALSE)
to transform it toRmd
- use
jupytext --to notebook script.Rmd
to createscript.ipynb
- share or execute the notebook