# R vs Python for Data Analysis [duplicate]

Possible Duplicate:
Python as a statistics workbench

I am just starting out with data analysis and machine learning. From the books that I am reading/have read Python and R seem to be the best options for me.

I want to know (in a general way) the pro's and con's of each, or if I should perhaps use both.

Up until now I have been learning C# but have taught myself Python to a competent level. What interests me is programming and finding solutions. I want to work on new thing where possible.

Any help would be greatly appreciated.

• Also see Python as a statistics workbench for some discussion of R and Python for data analysis. Jan 3, 2013 at 19:59
• This is very akin to endless debate. You may want to refine your question, e.g. by looking at Does Julia have any hope of sticking in the statistical community?
– chl
Jan 3, 2013 at 21:12
• @chl I have made my question a little more specific, is it better now? Jan 3, 2013 at 21:17
• Having used both extensively, I can say that Python has more existing development dedicated to evolutionary and online learners (GA, GP, RL, etc..). On the other hand I'm able to prototype ideas much more quickly with R.
– pat
Jan 3, 2013 at 21:21
• Depends on the problem and comfort level of each. I do go back and forth, but spend more time in R (almost stay in R, unless I can't find an existing library for the application or have extremely large datasets).
– pat
Jan 3, 2013 at 21:25

A good workman has several tools in his toolbox!

That said, do you see a distinction between C# and Python that adds to your toolbox?

R gives you access to thousands of statistical routines and techniques, plus great graphics. And it's a standard in the statistical world. (To be honest, I've noticed more Matlab in the Machine Learning community, but Matlab's an ugly language and expensive, so I'd feel guilty if I caused anyone to use it.) R is the best tool for actually analyzing data, except perhaps in the case of enormous data sets.

R's weakness, compared to C#, etc, would be its speed, its capacity to handle enormous data sets, and its development environment. So if you want to program things from scratch, use your favorite tool (C#, etc).

If you're mainly in data analysis mode, you might use Python to obtain and preprocess data, then feed it into R and carry on from there: explore, analyze, graph, etc. If you want to say, "I programmed my own Support Vector Machine implementation with the addition of Super Special Sprockets Mapping" use your favorite programming tool (C#, etc), then sanity check and display your answers with R.

I seriously doubt that you'll find Python libraries that implement all of the techniques that you'll find in R packages. But if you want to write code from scratch that really hasn't been done by others, a good programming language with a killer IDE is the way to go. (On the other hand, if you want to go to a Machine Learning website and download some code, those poor confused folks may well have Matlab code, which is nauseating, primitive, and write-only, in my opinion.)

• My answer would be pretty similar to Wayne's. I always use Python to parse through data. And I use R for statistical analyses, graphs, inference, etc. This has served me well. Just make sure you learn some shell scripting so it is easier to link the two. Technically you can do statistical analysis, graphing, etc. in Python, too, but the community support isn't nearly as strong in those areas as it is in R. Jan 4, 2013 at 5:16
• C# is what I have been learning in my course. Python, I feel, is more intuitive and more fun. I still have a lot to learn on all fronts but in my course it is mainly about app development and so I have had to teach myself the other things. Thanks for the advice! Jan 4, 2013 at 7:52
• I'd again reiterate that the development environment is very important for programming. I'm old-school and learned without fancy IDEs, but if I were learning now, I'd want something more. I like Python, and it also runs on all platforms (I use a Mac, for example). Jan 4, 2013 at 13:41
• @Wayne I'm using Eclipse with PyDev, VS 2012 and rStudio. Up until now I am very pleased with all of them. Any tips or suggestions? Jan 4, 2013 at 14:23
• R handles large datasets very well, but with specific tools, such as data.table with its lazy loading and memmap feature May 18 at 23:29