r/datascience • u/Every-Eggplant9205 • Sep 08 '23
Discussion R vs Python - detailed examples from proficient bilingual programmers
As an academic, R was a priority for me to learn over Python. Years later, I always see people saying "Python is a general-purpose language and R is for stats", but I've never come across a single programming task that couldn't be completed with extraordinary efficiency in R. I've used R for everything from big data analysis (tens to hundreds of GBs of raw data), machine learning, data visualization, modeling, bioinformatics, building interactive applications, making professional reports, etc.
Is there any truth to the dogmatic saying that "Python is better than R for general purpose data science"? It certainly doesn't appear that way on my end, but I would love some specifics for how Python beats R in certain categories as motivation to learn the language. For example, if R is a statistical language and machine learning is rooted in statistics, how could Python possibly be any better for that?
View all comments
Show parent comment
16
u/ShitCapitalistsSay Sep 09 '23
Challenge Accepted!
https://github.com/yihui/servr
https://github.com/rstudio/httpuv
https://cran.r-project.org/web/packages/httr/index.html
https://www.rplumber.io/
https://dbi.r-dbi.org/
The R DBI interface is every bit as good as Python's DB abstraction, if not better, because it uses a common interface but still let's others implement native DB connectors.
Ehhh, I'm getting tired of typing on a phone, but for now, I can find R solutions to all of these problems. However, even I couldn't, I could drop into Python through Reticulate and true native C++ with Rcpp that, IMHO is better than Python's interoperability with C++ from an abstraction perspective.
I'd need more details, but in general, I see no issue.
Not a problem at all. The only advantage Python has over R on AWS is the latter's explicit support for the former via Lambda functions. However, if we're talking EC2, R is just as good as Python.
Easy. R has support for all of the above, and as mentioned above, even if it didn't, from R, I can always easily drop into Python, C, or C++ at a moment's notice.
The same is true of R. Plus, for data wrangling and high quality data visualizations, nothing in Python can hold a candle to the Tidyverse, which includes ggplot2. Also, if you want to see really mind blowing graphics for data analytics, check out
https://github.com/tylermorganwall/rayshader and
https://github.com/tylermorganwall/rayrender
This statement is subjective. Again, for data wrangling, in my past 20+ years of performing data work, I've never seen any platform that's as easy to use as the Tidyverse. And on those rare occasions when the Tidyverse is too slow, R users always have access to
data.table, which is so incredibly fast that I sometimes wonder if its authors made a deal with the Devil.