Interaction - Random Facts
Both are good stable languages with interesting complementary qualities. You can get much better packages in one and then stitch them with some data from the other. An example is using time series forecasting and decision trees in R and doing data munging in Python.
Both languages borrow from each other. Even seasoned package developers like Hadley Wickham (Rstudio)
borrows from Beautiful Soup (python)
to make rvest
for web scraping. In addition to that, Yhat
borrows from sqldf
to make pandasql
and many other.
Rather than reinvent the wheel in the other language developers can focus on innovation because, in the end, the customer does not care which language the code was written, the customer cares for insights.
Mixing Them Up
AM mentioning few approaches to mix them together-
Use a Python package rpy2
to use R within Python . [Demo]
Use Python from within R using the rPython package
. [Demo]
Use Jupyter
with the IR Kernel
. Python and R and makes the interactivity of iPython available to other languages.
Use Beaker Notebook. It 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.
Python vs R
Python vs R - This section will answer:
- Which will be better?
- How to choose one over other?
- Specialization
See as I said earlier both are stable and you can choose any or work with both. But when it comes to master one I'll suggest keep these 3-4 guidelines in mind-
Personal Preference
Choose the language to begin with based on your personal preference, on which comes more naturally to you, which is easier to grasp from the get-go. To give you a sense of what to expect, mathematicians and statisticians tend to prefer R, whereas computer scientists and software engineers tend to favor Python.
Project selection
You can also make the Python vs. R call based on a project you know you’ll be working on in your data studies. If you’re working with data that’s been gathered and cleaned for you, and your main focus is the analysis of that data, go with R. If you have to work with dirty or jumbled data, or to scrape data from websites, files, or other data sources, you should start learning, or advancing your studies in, Python.
Collaboration
Once you have the basics of data analysis under your belt, another criterion for evaluating which language to further your skills in is what language your teammates are using. If you’re all literally speaking the same language, it’ll make collaboration—as well as learning from each other—much easier.
Job market
Jobs calling for skill in Python compared to R have increased similarly over the last few years.
Note: Have a look at this infographic by DataCamp. For a better view on it.
My Rationale
In my case am doing both and using them interactively and Customizing them as per my use. You can get something really interesting in one (as I mentioned above) which will be hardly available in other, so it's better to use both together. This is the best way to bridge the gap between these two.
But in the last, it's your call keep the guidelines, your interest, and scenarios in mind and make a clear view on that.
Strength & Weaknesses
R
Strength
- R is great for prototyping and for statistical analysis.
- It has a huge set of libraries available for different statistical type analysis. Check The Comprehensive R Archive.
- RStudio IDE is a definitely a big plus. It eases most of the tedious tasks and fastens your workflow.
Weaknesses
- The syntax could be obscure sometimes.
- It is harder to integrate to a production workflow.
- In my opinion, it is better suited for
consultancy-type
tasks.
- The libraries documentation isn't always user friendly.
Python
Strength
- Python is great for scripting and automating your different data mining pipelines. It is the de facto scripting language nowadays.
- It also integrates easily in a production workflow. Besides, it can be used across different parts of your software engineering team
(back-end, cloud architecture etc.)
.
- The scikit-learn library is awesome for machine-learning tasks.
- Ipython (and its notebook) is also a powerful tool for exploratory analysis and presentations.
Weaknesses
- It isn't as thorough for statistical analysis as R, but it has come a long way these recent years
- In my opinion, the learning curve is steeper than R, since you can do much more with Python.
The Conclusion
Use R and Python. Learn how they inter-operate together. Start with one and then add the other to your workflow. As I like to remind myself- "choosing the tools should never be the primary problem". When in doubt, use the one that is available and that gets the work done quickly.
Hope it helps!
Ref- Udacity, Quora, Letustweak, kD, DataCamp