From the course: Introduction to Data Science

Comparing Python and R

R and Python are among the most popular languages for data science, and each has its supporters and opponents. I want to help you understand the differences and provide a basic comparison between these two languages and point out the strengths of each. Python is generally used when data analysis tasks need to be integrated with web applications, or statistical code needs to be incorporated into a production database. Meanwhile, R is mainly used when the data analysis tasks require standalone computing or analysis on individual servers. Python emphasizes productivity and code readability. In contrast, R focuses on better user-friendly data analysis statistics and graphical models. Python is used by programmers that want to delve into data analysis or apply statistical techniques and by developers that turn to data science. On the other hand, R has been used primarily in academics and research. However, it's rapidly expanding into the enterprise market. Coding and debugging is easier to do in Python due to Python's nice syntax. The indentation of the code affects its meaning. A piece of functionality is always written the same in Python. Meanwhile, statistical models can be written with only a few lines in R. There are style sheets in R, but not everyone uses them and the same piece of functionality can be written in several ways in R. Python's focus on readability and simplicity makes its learning curve relatively low, and Python is considered a good language for new programmers. However, R has a steep learning curve at the beginning. Once you know the basics though, you can easily learn advanced techniques. R is not hard for experienced programmers. PyPi stands for Python Package Index and it's a repository of Python software consisting of libraries. Users can contribute to PyPi, but it's a little bit complicated in practice. And CRAN stands for the Comprehensive R Archive Network. It's a huge repository of R packages that users can easily contribute to. Python and R both have strengths and weaknesses, and depending on your needs, you might find yourself using one, the other, or both.

Contents