R or Python…Both?

Well, this seems to be an endless debate, which is better R or Python? What should be my learning track if I am an aspiring Data Scientist ? Well, I don’t have the answer yet.

But it looks like the world is already moving to converge the power of R with the simplicity of Python, presented in form of the rpy packages.

What is rpy?

As stated above, it is a python package that helps you use R inside python, providing an interface between the two. It basically enables you to create R objects, which in turn invokes the functions of R. It can help you call any function of R, even the high level graphical libraries. What seems to be the best part is that all the errors and exceptions it encounters while calling R, gets converted into python trackback errors.

What is rpy2?

No, points for guessing. ryp2 is the upgraded version of rpy. As stated in the official rpy2 documentation

rpy2 is a redesign and rewrite of rpy.

Prerequisites:

R and Python installed 😛

pip installed .

sudo apt-get install python-pip (just in case)

Check if installed previously

$python

>>> import rpy2

>>> rpy2.__version__

>>rpy2.__path__

#if you get an error while importing, then rpy2 is not installed.

How install it?

pip install rpy2.

Redo the testing

Expected output:

bg5

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s