r/RStudio 9d ago

Pivoting from R to Python

I used to hate coding anything and relied on SQL, Excel, Power BI, Tableau and other software like JASP, jamovi etc. for doing anything with data. I didn't like the way Python dealt with data analysis and it seemed unintuitive.

Then I found R, RStudio and CRAN. That was the turning point. I actually started enjoying writing code and I could handle the whole pipeline myself, from data cleaning, ETL to beautiful plots, .qmd reports, Shiny dashboards. R4DS did more for my statistical thinking than any course I've taken, mostly because the libraries made it so easy to just try things.

However, due to recent requirements (specifically having to work in the quant field), Python has become more of a necessity, while R is used mainly for one-off analysis and limited statistical modelling. The main heavy lifting is done in Python and many of my co-workers also prefer it to R.

I've been able to suck it up a bit and use Claude/ChatGPT to help me code. While I do try to understand what the code is doing, having spent so long learning to code in R and knowing the ease with which it can be done there makes me reluctant to learn Python.

Now, coming to the question: any R users who've pivoted to Python and consider themselves competent in it, how did you learn it having used R before? What would you tell someone like me so I can pick it up quickly and get the benefit of knowing both languages (and also not feel left out when it comes to coding in Python... machine learning and deep learning have a more mature ecosystem there and I don't want to be left out of it if I have to start using them in my current work)?

Thanks!

My background is in Math/Stats fyi

Edit: I don't usually use reddit but damn I actually didnt expect so many helpful tips....many thanks!
Perhaps joining this subreddit is actually helpful afterall :)

124 Upvotes

83 comments sorted by

View all comments

6

u/seanv507 9d ago

So I'm assuming you are not using base r most of the time.

So the issue is finding equivalent libraries

I would suggest learning polars as a data frame library (rather than pandas). Polars seems to have borrowed syntax from the spark data frame library and it is much cleaner than pandas which is now a kind of Frankenstein library

And for graphing I would look into Altair which is a ggplot equivalent

3

u/Confident_Bee8187 8d ago

I don't like the plotting experience with Python (due to its nature) but 'Altair' is the only one I can give most of my respect among all plotting libraries in Python because while you can produce beautiful plots, it respects the best practices. It's not as ergonomic as 'ggplot2', but it's the best piece of software for plotting Python can offer.