See main Approaches to Using Python and R together


Image result for how to use python and R together



Well if Data Science and Data Scientists can not decide on what data to choose to help them decide which language to use, here is an article to use BOTH.


Why would anyone want to use R and Python in the same software? Have we not seen enough debates on the internet on which language is better. f Data Science and Data Scientists cannot decide on what data to choose to help them decide which language to use, here is an article on how to use BOTH.

Here are some reasons to do so:
1.    Both are good stable languages with interesting complementary qualities. You can get much better packages in one and then stich them with some data from the other. An example is using time series forecasting and decision trees in R

2.    Both languages borrow from each other. Even seasoned package developers like Hadley Wickham (Rstudio) borrow from Beautiful Soup (python) to make rvest for web scraping. Yhat borrows fromsqldf to make pandasql. Rather than  reinvent the wheel in the other language developers can focus on innovation
3.    The customer does not care which language the code was written, the customer cares for insights.

4.    You are less likely to be tied down due to a bug or feature request or a version compatibility issue

5.    It is sexier for data scientists to be skilled on (or cooler as we older guys liked to say before Harvard Business Review proclaimed data scientist as the sexiest job)

6.    There are only four main languages within Data Science (~91% by KDnuggets Poll) and everyone can use SQL from their own language. There is no debate on SQL.

You can actually call it from either way –
  • rPython - an R package which allows the user to call Python from R
  • rpy2 - Python interface to the R language (embedded R). It allows users to call R from Python
 But here are three principal ways to use Python an R

1.    Use a Python package rpy2 to use R within Python. You can also use Python from within R using the rPython package
2.    Use Jupyter with the IR Kernel - The Jupyter project is named after Julia Python and R and makes the interactivity of iPython available to other languages
3.    Use Beaker notebook -Inspired by Jupyter, Beaker Notebook allows you to switch from one language in one code block to another language in another code block in a streamlined way to pass shared objects (data)
Now remember that  all these methods are not simple and streamlined . I enjoy Python’s power in data munging and I enjoy R’s huge library of packages and functions for statistics.

1 comment: