Convert RMarkdown files to Jupyter Notebook

Convert your work from RStudio to generate blog posts

  • toc: true
  • branch: master
  • badges: true
  • comments: true
  • author: Francesco Gastaldello
  • categories: [first steps, R, jupyter]

Many of the people at CorrelAid come from a R background. Even you (the reader) could be more familiar to the R world than to the Python one.
To help you all to easily display your work on the Correlaid blog, here we will introduce a couple of methods to convert R Mardown files into Jupyter Notebook ones.

These are:

  • Jupytext: a Python package that provides two-way conversion between Jupyter Notebooks and several other text-based formats like Markdown documents or scripts.
  • Notedown: a simple tool to create IPython notebooks from markdown (and r-markdown).

Working with Jupytext

Installation

To install Jupytext, open a terminal (Unix) or a command line window (Windows) and run:

pip install jupytext --upgrade

If you use conda instead, run:

conda install jupytext -c conda-forge

Convert a R Markdown file

Once the package is installed, using the same Python distro that is used for your Jupyter Notebook/JupyerLab, you can convert a R Markdown file by following these steps:

  1. Open a terminal (Unix) or a command line window (Windows).
  2. Navigate to your script.Rmd file location.
  3. Run jupytext --to notebook script.Rmd to have a script.ipynb file.
  4. Make sure that the conversion is correct by opening the newly created notebook via Jupyter Notebook/JupyterLab.
  5. Share your content on the CorrelAid blog!

Please refer to the project page for further references.

Working with notedown

Installation

To install notedown, open a terminal (Unix) or a command window (Windows) and run:

pip install notedown

Convert a R Markdown file

Once the package is installed, make sure that you have knitr instaled as well with your R instance.
In a terminal (Unix) or command window (Windows) run:

notedown script.Rmd --knit > script.ipynb

Before sharing your content, make sure that the conversion is correct by opening the newly created notebook via Jupyter Notebook/JupyterLab.

Please refer tot he project page for further references.