Comparative analysis of R and Python for mathematical
programming
R and python are the frontrunners these days for the mathematical programming. R is
favored for the statistical and data analysis and stands out as a direct and a strong opponent
for SAS. But in past few years python has equipped itself with powerful tools for data
analysis and has been giving competition to R especially for small and mid-sized problems.
Python and R both are powerful for data analysis and come with a lot of packages for solving
data problems.
Python is an open source scripting language which has grown over time. It has libraries
such as scipy, numpy,matplotlib ,pandas for the mathematical programming and data
analysis for the structured data.
Advantages of a python based solution
General purpose programming language so we can implement complex algorithms easily.
Scales very easily
An object oriented approach*(Not very relevant for the data analysis)
Threading and parallel processing is an option.
Documentation is coherent and readable.
Availability of many IDE for development purpose(Not very relevant)
Challenges with python
Size of the community is small.
Not a professional support available
R
Advantages of R
R is a mature solution as compared to python .
Vast libraries and many APIs for a single problem.
Professional Support is available in the form of Revo R in case we go ahead and purchase
license. Even if you dont purchase license R community is strong.
Quick results.
Challenges with R
R involves a steep learning curve.
Not an object oriented language (Not very relevant for data analysis)
Low level programming language, a simple procedure takes a lot of code writing.
Threading is not available.
Data is copied via call by value than call by reference , so it has some memory cost
associated with it.
Comparison Matrix
There are many attributes on the basis of which the two can be compared. The real
bottlenecks for any mathematical, statistical package is the implementation of the models
and mathematical functions which are time consuming and increase the space and time
complexity of the algorithm in general.
For basic operations with data R and python offer similar results but R offers a long range of
stats library
For data analysis from the machine learning perspective python is generally recommended
while the data analysis from the statistical purposes R is highly used.
Development speed: Python > R
Execution speed for large data: R > Python
Currently R is the real competitor of SAS but python has a promising future.
Parameter
Availability/Cost
Python
Open Source
Ease of Learning
Community
Known for the
simplicity
Pandas lib has
introduced data
frame capability
Matplotlib library
allows calling R
libraries for graphs
Strong community
Documentation
Coherent
Typical Uses
Major disadvantage
Nonlinear constrained
optimization support*
Engineering
Not very mature
Scipy.optimize()
Uses Newton
Conjugate gradient
algorithm
License
BSD
Data handling capability
Graphical capabilities
R
Open Source(Commercial
version provided by
Revolution analytics)
Very steep learning curve
Can be scaled using Hadoop,
not an in memory limited
solution any more
Best in class graphical
representations available
Very strong community and
prompt solutions available
A lot of people develop their
own libraries, so
documentation is not in
depth for few of them.
Finance and Statistics
Very steep learning curve
Optimx(),nloptr(),optim()etc
Uses Newton conjugate
gradient algorithm (Interior
point algo is there but used
in quadratic and cone
programming packages)
GPL , LGPL, BSD , MIT
licenses associated with
various packages of R
*SAS uses Interior point algorithm
Sources:
http://programmers.stackexchange.com/questions/181342/r-vs-python-for-data-analysis
http://www.analyticsvidhya.com/blog/2014/03/sas-vs-vs-python-tool-learn/
http://blog.revolutionanalytics.com/2013/12/r-and-python.html
https://www.kaggle.com/forums/t/5243/pros-and-cons-of-r-vs-python-sci-kit-learn
http://brenocon.com/blog/2009/02/comparison-of-data-analysis-packages-r-matlab-scipyexcel-sas-spss-stata/