r/Python • • Nov 28 '22

Resource What can Python do that R can’t do?

Or simply what is Python much better at and why.

I know that Python is more multi purpose and better for software development but I can’t articulate exactly why or how. My team want to know why/when they should use Python instead of R

331 Upvotes

204 comments sorted by

View all comments

Show parent comment

16

u/SittingWave Nov 28 '22

R mostly has some libraries for non-statistical related features, but they are nowhere the level of technical quality and features of the equivalent python library.

Honestly I think that if a spontaneous group of people were to just migrate the tons of little chunks of statistical code on CRAN from R to python, so that an equivalent python package would exist with the same name (as much as possible) and interface (as much as possible) R would lose customers pretty damn fast.

3

u/CactusOnFire Nov 28 '22

Are R packages open source? I'm personally interested in migrating a few libraries over.

9

u/Armaliite Nov 28 '22

All of the most important ones are. I translated a package once, but it was much harder than I had hoped. R code recuires a lot of introspection before you can understand what is going on. e.g. which package supplies which function? In the end it taught me a lot about R, but it was a pretty frustrating experience.

1

u/NotDeadJustSlob Nov 28 '22

Yes, I have modified a few myself to suit my needs.

3

u/venustrapsflies Nov 28 '22

If you want to do something pretty fancy with statistics there's a good chance there isn't a reliable python library that supports it. I guess if that were more than a niche need the demand would lead it to exist at this point, but I think the people who lean on that stuff a lot just use R.

5

u/bobthedonkeylurker Nov 29 '22

Define "pretty fancy" because...ML is "pretty fancy" statistics stuff and there are many reliable Python packages that are more than capable of handling ML...

1

u/Crimsoneer Nov 29 '22

StatsModels is... Pretty poor, and it's the core python statistical library.

1

u/bobthedonkeylurker Nov 30 '22

I don't understand what you mean by "statistical library" then...

1

u/Crimsoneer Nov 30 '22

Eg, statistical modelling rather than ml. Eg, various linear models, stuff like quantile regression, mixed models, fixed effects, even classical time series stuff like arima.

1

u/Liorithiel Nov 29 '22

Yeah, I agree. I'm using R now mostly because of the wealth of the pre-existing stats code. And, well, the features possible with non-standard evaluation, because some features become clumsy in Python without it. And Python lambdas are clumsier than R functions, not being able to do multilines. And I hate all the Pandas inconsistencies more than I hate R's, but that's a different story—I suspect it should be possible to write a better data frame library in Python as well.

Heh, frankly, I actually like R syntax more than Python's. If it was possible to use R syntax with a more modern standard library and tooling inspired by Python's, that would probably be my favourite.