Dr. Avit Bhowmik | Environmental Scientist · Climate Solutionist

R or Python?

Image credit: Jacob Bedard       

I have been facing this question since 2012, during my job at the Institute for Geoinformatics, and have recently discussed it with my colleagues at Stockholm Resilience Centre. I am surrounded by modellers who prefer Python over R, more for tradition than practicality in my opinion.

R and Python are both object oriented scripting languages, where, originally, R was designed for statistical analyses and Python for software and application development. I have worked with both (from coding architecture they are not much different), however, have always preferred R, not only because that my activities were more concentrated on the data analysis part than the software development but also because of the type of data I was analyzing, i.e. large scale spatiotemporal data.

The figure is created and copyrighted by datacamp, and is only symbolically used in this post. See here for the details on this figure.

R is the most advanced tool in the market for spatiotemporal geostatistics (with the ‘gstat’ and ‘spacetime’ packages) and raster data analyses (with the ‘raster’ package). It offers an unique ground for storing and integrating space and time attributes of data, and enables their implementation and integration through the analyses. Raster data analysis has not only become faster and more efficient than before but also more intuitive. The thing I love about R is it’s capability of co-interfacing with a wide range of software that is much more vast than Python. In fact, it provides packages to co-interface with Python itself (with the ‘rpython’ package for example), and also allows for using Python’s spatial modules (with the ‘RPyGeo’ package). Moreover, R is much more user friendly than Python in terms of compact coding, i.e. integrating several functions in one line of code. People may argue that Python has the advantage in software development, but I have developed two tools so far using R and without needing Python.

A few recent discussions in Quora and datacamp also eventually voted for R.