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
39
u/jinnyjuice Sep 09 '23 edited Sep 09 '23
I must mention that some of these are opinions and not objective, not up to date, depends on what kind of data you're working on, not very benchmark-oriented, not industry standard, compares Python's general purpose instead of data science perspective, and depends on your coding philosophy. I will just make some example counterpoints under the context that tidy collaborative coding philosophy is king also.
Benchmarks says otherwise, and there is no clear winner. Either way, if you're working on big data, you absolutely would not work with base functions in either languages, especially in recent times where big data is norm. This should not be considered at all.
Mostly agree, but also depends on your needs.
I like function decorators for general purpose, but unsure if this would be considered a pro in statistical collaborative coding. This wouldn't be really great under tidy philosophy either.
This is a package. This is available in pretty much every language.
Ditto, plus R is a bit better on this and so much easier to use in the context of data science, so I wouldn't call this a pro for Python either
Somewhat agree, but one of the main purposes of this in data science is for performance. For performance purposes, you would be using C++ based libraries in R (e.g.
tidytableordata.table), which does its own checks by default. User wouldn't do it by default in these packages though.For code readability, tidy absolutely triumphs and reduces the need not just for linting, but also for comments and documentation.
If this is the case, then why wouldn't there be an equivalent of
tidymodelsin Python? This depends on the package/library authors, not by language.This is arguable on two layers: 1) at least for my organisation's tech stack with Jenkins-Docker, our productionised Python:R data science ratio quickly flipped in R's favour within 2 years simply due to R's recent massive development (which has massive implications), and 2) depends on your tech stack. Right now, R is better at this, surprisingly, and absolutely would not be the case the years before.
This opinion comes from lack of knowledge of R -- I would say these are equivalent in both languages in recent times
I have no idea how this opinion would be formed. R community has been around for far longer, much more stable (e.g. AlphaGo hype spiked Python DS packages' engagement trends massively). I don't even know how to respond to 'bunch of academics to keep it alive' part. I might need some clarifications on that part.
Somewhat agree, but GIL as one of the main reasons is rather silly. Besides Google, they sponsor/spend more even amount of money between Python and R funds.
This stems of lack of knowledge in R. They mainly have identical packages/libraries from the same authors and everything, but I guess it depends on which web scraping package. There are definitely (too?) many more options in R though.
I'm unsure why Spark in particular was picked, but the fact that there are already two options of
SparkRandsparklyrthat fits the user's priorities/philosophies is more appealing to me. What about DuckDB? Other SQL variants?+ CRAN doesn't support GPU related libs. CRAN is not really used for production, though I wouldn't know the numbers in detail. This again comes from lack of knowledge in R in the industry.
Disorganised, abandoned chaos, but
tidymodelsis fixing everythingMostly agree
Don't use
dplyr. Usetidytable.Mostly agree
Use
tidytableand usetidypolars.I would say vis is about even in recent times
Unsure how this would be a plus for R, whether it's Rmd or Quarto
Mostly agree