Data

R interface to Python via the Reticulate Package

1 min read

Announcing the Reticulate package, an R interface to Python. This package consists of comprehensive set of tools for interoperability between Python and R.

With this new package, one can:

  • Call Python from R in several ways including R Markdown, sourcing Python scripts, importing Python modules, and using Python interactively within an R session.
  • Translate between R and Python objects (for example, between R and Pandas data frames, or between R matrices and NumPy arrays).
  • Bind to different versions of Python including virtual environments and Conda environments in a flexible manner.
  • Reticulate embeds a Python session within one’s R session, enabling seamless, high-performance interoperability.
  • It can dramatically streamline the workflow for R developers who use Python for their experiments or for a member of data science team that use both the languages.

Python in R Markdown

The reticulate package also includes a Python engine for R Markdown which has following  features:

  • It can run Python chunks in a single Python session embedded within one’s R session (shared variables/state between Python chunks)
  • Prints 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)

Built in conversion for many Python object types is provided, including NumPy arrays and Pandas data frames. One can also use Pandas to read and manipulate data, and easily plot the Pandas data frame using ggplot2.

Read more about the Reticulate package in detail on R Studio GitHub Repo

 

Savia Lobo

A Data science fanatic. Loves to be updated with the tech happenings around the globe. Loves singing and composing songs. Believes in putting the art in smart.

Share
Published by
Savia Lobo

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago