The reticulate package provides a comprehensive set of tools for interoperability between Python and R.
The package includes facilities for:
- Calling Python from R in a variety of ways including R Markdown, sourcing Python scripts, importing Python modules, and using Python interactively within an R session.
- Translation between R and Python objects (for example, between R and Pandas data frames, or between R matrices and NumPy arrays).
- Flexible binding to different versions of Python including virtual environments and Conda environments.
reticulate embeds a Python session within your R session, enabling seamless, high-performance interoperability. If you are an R developer that uses Python for some of your work or a member of data science team that uses both languages, reticulate can dramatically streamline your workflow.
Features include:
- Offers different ways to integrate Python code into R projects:
- Python in R Markdown — A new Python language engine for R Markdown that supports bi-directional communication between R and Python (R chunks can access Python objects and vice-versa):
- Run Python chunks in a single Python session embedded within your R session (shared variables/state between Python chunks).
- Printing of Python output, including graphical output from matplotlib.
- Access to objects created within Python chunks from R using the py object (e.g. py$x would access an x variable created within Python from R).
- Access to objects created within R chunks from Python using the r object (e.g. r.x would access to x variable created within R from Python)
- Importing Python modules — The import() function enables you to import any Python module and call it’s functions directly from R.
- Sourcing Python scripts — The source_python() function enables you to source a Python script the same way you would source() an R script (Python functions and objects defined within the script become directly available to the R session).
- Python REPL — The repl_python() function creates an interactive Python console within R. Objects you create within Python are available to your R session (and vice-versa).
- Python in R Markdown — A new Python language engine for R Markdown that supports bi-directional communication between R and Python (R chunks can access Python objects and vice-versa):
Website: rstudio.github.io/reticulate
Support: GitHub Code Repository
Developer: jjallaire, Tomasz Kalinowski, Kevin Ushey, and other contributors
License: Apache License 2.0
reticulate is written in R. Learn R with our recommended free books and free tutorials.
Related Software
| Access Python from R | |
|---|---|
| reticulate | R Interface to Python |
| basilisk | Smooth interoperability of multiple Python environments in a single R session |
Read our verdict in the software roundup.
Explore our comprehensive directory of recommended free and open source software. Our carefully curated collection spans every major software category.This directory is part of our ongoing series of informative articles for Linux enthusiasts. It features hundreds of detailed reviews, along with open source alternatives to proprietary solutions from major corporations such as Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk. You’ll also find interesting projects to try, hardware coverage, free programming books and tutorials, and much more. Discovered a useful open source Linux program that we haven’t covered yet? Let us know by completing this form. |

