Python VS R. Coding Star Wars!

Soledad Musella Rubio
4 min readOct 24, 2020

In one of my previews blogs I’ve talked about the difference between Machine Learning and Programming Languages. When talking about programming languages, I have inserted a table in which the different programming languages were mentioned. Below you can review it:

You can see from above that the number of Programming Languages is extremely wide. Coming back specifically to Data Science, the two most popular programming languages are R and Python. In this blog I will analyse the pros and the cons of both of them and I will declare which one is the winner, given my personal experience and point of view.

Python

Python is quite an old programming language, in fact it was designed by Guido van Rossum in 1991 and developed by Python Software Foundation. Due to his intuitiveness it is utilised for various purposes such as developing, scripting, generation and software testing. Python is an interpreted language. The programmer can directly issue commands using the command line or can use an IDE. The most common IDE for Python is PyCharm and Eclipse. They contain the code editor, debugging features, and so on for developing Python applications.

Different types of data can be stored using Python. They can be numeric values or strings. Python supports data structures such as lists, tuples and dictionaries. A list can be used to store multiple data items of different types. A list is mutable, so it can be edited. A tuple is also used to store multiple elements of the same type but it is an immutable Python object. Dictionaries are used to store key, value pairs. Those are the main data structures in Python.

Python can be used to create graphical user interfaces and one of its coolest things is that can be integrated with databases such as MySQL, MSSQL, etc. It is useful for a variety of applications, in fact it can be used for machine learning, web development, networking, scientific computing, automation, natural language processing, and more.

R

R is a programming language and software environment for statistical analysis, reporting to represent graphics. The main advantage of using R is that it can be used to implement statistical concepts such as linear and non-linear modeling, time series analysis, clustering etc.

R is an interpreted language, so each line is read one after the other by the interpreter. It is a high-level programming language. There is a command line interpreter so that the programmer can directly enter commands in the command line. RStudio is the common integrated development environment (IDE) to simplify R programming. It includes code editors, debugging and visualization tools. There are also packages like ggplot2 and dplyr which further extend the features of R.

During programming, it is necessary to store the values. In fact, R can store several types of values. It can store logical data types such as true and false. It can also store numeric values, characters and complex numbers. R has several data structures such as vectors, lists, matrices, matrices, factors and data frames. A vector can be used to store more than one element. A list can contain many different data types of elements such as vectors or another list. An array can be used to store the two-dimensional dataset. Arrays are used to store a dataset of any number of dimensions. Factors are objects r created with a vector. Data frames are used to store tabular data objects. Those are the main data structures in R.

Similarities

  • Both are multi-paradigm programming languages. They support object-oriented programming, imperative programming, procedural programming etc.
  • Both can be used to develop algorithms.
  • Both are interpreted languages.
  • Both are free and open source.
  • Both can be integrated with databases such as MySQL, Oracle etc.
  • Both of them support different files like CSV file, excel file, XML file and JSON file.

Differences

  • R is more “statistical” focused.
  • Python is more “data science” focused.
  • R users mainly consists of Scholars and R&D professionals while Python is mainly used by Programmers and Developers.
  • With Python is easy to built models from scratch while R provides flexibility to use available libraries.
  • R can be more difficult to learn at the beginning compared to Python that is more intuitive and simple.
  • R is integrated to Run locally while Python is well-integrated with apps
  • R can be used on the R Studio IDE while Python can be used on Spyder and Ipython Notebook IDEs

Conclusion

After having reported the characteristics of both of them, my final considerations are that neither can be declared an absolute winner. In fact, the quality of their performance depends especially on the field in which they are applied. In some contexts R performs more in others Python can perform more and vice versa.

Thanks for reading!

sources : https://www.guru99.com/r-vs-python.html, https://en.wikipedia.org/wiki/Python_(programming_language)

--

--