r/statistics • • Apr 19 '18

Software Is R better than Python at anything? I started learning R half a year ago and I wonder if I should switch.

I had an R class and enjoyed the tool quite a bit which is why I dug my teeth a bit deeper into it, furthering my knowledge past the class's requirements. I've done some research on data science and apparently Python seems to be growing faster in the industry and in academia alike. I wonder if I should stop sinking any more time into R and just learn Python instead? Is there a proper GGplot alternative in Python? The entire Tidyverse package is quite useful really. Does Python match that? Will my R knowledge help me pick up Python faster?

Does it make sense to keep up with both?

Thanks in advance!

EDIT: Thanks everyone! I will stick with R because I really enjoy it and y'all made a great case as to why it's worthwhile. I'll dig into Python down the line.

140 Upvotes

153 comments sorted by

View all comments

Show parent comment

15

u/marrone12 Apr 19 '18

I started learning R with plyr nearly 10 years ago. Dplyr came out more recently.

As far as intuitive, pandas vs R for simple things like subsetting: Python: data.loc[data['id']==25822] Vs R: filter(data, id == 25822)

I feel like R's syntax is easier to understand for someone coming from excel. But to each their own.

7

u/tsunamisurfer Apr 19 '18

Even simpler with data.table: data[id==25882]

5

u/nsfy33 Apr 19 '18 edited Mar 07 '19

[deleted]

4

u/marrone12 Apr 19 '18

The way I did it five years ago was to do subset(data, id == 25822)

2

u/[deleted] Apr 19 '18 edited Apr 19 '18

You could do something like this 10 years ago (and probably more):

iris ->.
  subset(., Species == "virginica") ->.
  subset(., select=c("Sepal.Width", "Sepal.Length")) ->.
  colMeans(.)

all in base R.

2

u/dialecticalmonism Apr 19 '18

In Pandas there are multiple ways to accomplish the same thing. In this case, you could just use:

data[data.id == 25822]

2

u/marrone12 Apr 19 '18

Had no idea that worked. All the official documentation and stack overflow always uses the ix and loc methods.

3

u/dialecticalmonism Apr 19 '18

Yeah, the fact that you can do things in multiple ways within Pandas definitely cuts both ways.

3

u/figurative1y Apr 19 '18

You can also use pipes:

data %>% filter(id == 25822)

3

u/marrone12 Apr 19 '18

Yeah I'm aware of pipes just wanted to keep it simple for the example