Reticulate: a RStudio package to use both R and Python from R Markdown

reticulate: R interface to Python

Do you love working with Python, but just can’t get enough of ggplot, R Markdown or any other tidyverse packages. You are not alone, many love both R and Python and use them all the time. Now RStudio, has made reticulate package that offers awesome set of tools for interoperability between Python and R.

One of the biggest highlights is now you can call Python from R Markdown and mix with other R code chunks. And yes you can load the data with Pandas in Python and use the pandas dataframe with ggplot to make cool plots.

Not just that, now you can source your python scripts, just like you have been sourcing your R scripts.

Reticulate has made it easy to translation between R and Python objects. For example, it is much easier to go from R dataframes to Pandas data frames, or R matrices to NumPy arrays).

One of the advantages of Python is the virtual environments, where you can different versions of Python and its packages separately. All you need to do is create a specific virtual environment for each version you want and use it virtual environment when you need. Reticulate allows you use specific virtual environment that you like.

Learn more about reticulate package from

  1. RStudio blogpost announcing reticulate package
  2. reticulate website

Here are some cool examples of getting started with reticulate to use R and Python from R Markdown

reticulate: using R and Python from R Markdown
reticulate example in R markdown