Answers.Body: <p>Of course, this type of questions will also lead to primarily opinion-based answers. Nonetheless, it is possible to enumerate the strengths and weakness of each language, with respect to machine learning, statistics, and data analysis tasks, which I will try to list below.</p>
  
  <h2>R</h2>
  
  <h3>Strengths</h3>
  
  <ul>
  <li><p>R was designed and developed for statisticians and data analysts, so it provides, <a href="https://en.wikipedia.org/wiki/Out_of_the_box_(feature)" rel="noreferrer">out-of-the-box</a> (that is, they are part of the language itself), features and facilities for statisticians, which are not available in Python, unless you install a related package. For example, the data frame, which Python does not provide, unless you install the famous Python's <a href="https://pandas.pydata.org/" rel="noreferrer"><code>pandas</code></a> package. There are other examples like matrices, vectors, etc. In Python, there are also similar data structures, but they are more general, so not specifically targeted for statisticians.</p></li>
  <li><p>There are a lot of statistical libraries.</p></li>
  </ul>
  
  <h3>Weakness</h3>
  
  <ul>
  <li>Given its purpose, R is mainly used to solve statistical or data analysis problems. However, it can also be used outside of this domain. See, for example, this Quora question: <a href="https://qr.ae/TWvefg" rel="noreferrer">Is R used outside of statistics and data analysis?</a>.</li>
  </ul>
  
  <h2>Python</h2>
  
  <h3>Strengths</h3>
  
  <ul>
  <li><p>A lot of people and companies, including Google and Facebook, invest a lot in Python. For example, the main programming language of TensorFlow and PyTorch (two widely used machine learning frameworks) is Python. So, it is very unlikely that Python won't continue to be widely used in machine learning for at least 5-10 more years.</p></li>
  <li><p>The Python community is likely a lot bigger than the R community. In fact, for example, if you look at <a href="https://www.tiobe.com/tiobe-index/" rel="noreferrer">Tiobe's index</a>, Python is placed 3rd, while R is placed 20th.</p></li>
  <li><p>Python is also widely used outside of the statistics or machine learning communities. For example, it is used for web development (see e.g. the Python frameworks Django or Flask).</p></li>
  <li><p>There are a lot of machine learning libraries (e.g. TensorFlow and PyTorch).</p></li>
  </ul>
  
  <h3>Weakness</h3>
  
  <ul>
  <li>It does not provide, out-of-the-box, the statistical and data analysis functionalities that R provides, unless you install an appropriate package. This might be a weakness or a strength, depending on your philosophical point of view.</li>
  </ul>
  
  <p>There are other possible advantages and disadvantages of these languages. For example, both languages are dynamic. However, this feature can both be an advantage and a disadvantage (and it is not strictly related to machine learning or statistics), so I did not list it above. I avoided mentioning opinionated language features, such as code readability and learning curve, for obvious reasons (e.g. not all people have the same programming experience).</p>
  
  <h2>Conclusion</h2>
  
  <p>Python is definitely worth learning if you are studying machine learning or statistics. However, it does not mean that you will not use R anymore. R might still be handier for certain tasks. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-05T14:34:19.617Z
Answers.Text: It seems like the "out of the box" feature set is irrelevant.  The relevant thing is the availability of packages that do what you want, no?
Answers.UserDisplayName: Dean MacGregor
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-05T17:44:14.330Z
Answers.Text: @DeanMacGregor If you do not have access to the internet, this feature is relevant! Furthermore, if a programming language already provides a feature out of the box, you do not have to lose time looking for it.
Answers.UserDisplayName: nbro
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-07T07:06:36.613Z
Answers.Text: Considering Python is heavily infested on being 'batteries included', its weakness is not one you encounter often. Especially since there are Python installations in use which *do* have statistical packages included. For data science in particular, [Anaconda](https://www.anaconda.com/distribution/) is quite popular and solves your immediate concern.
Answers.UserDisplayName: Mast
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-04T23:16:27.707Z
Answers.LastActivityDate: 2019-08-04T23:16:27.707Z
Answers.UserDisplayName: nbro
Answers.Body: <p>I didn't have this choice because I was forced to move from R to Python:</p>
  
  <p>It depends on your <strong>environment</strong>: When you are embedded in an <strong>engineer</strong> department, working technical group or something similar than Python is more feasible.</p>
  
  <p>When you are surrounded by <strong>scientists</strong> and especially <strong>statisticians</strong>, stay with R.</p>
  
  <p>PS: R offers keras and tensorflow as well though it is implemented under the hood of python. Only very advanced stuff will make you need Python.
  Though I'm getting more and more used to Python, the synthax in <strong>R is easier</strong>. And though each package has its own, it is somehow consistent while Python is not..
  And ggplot is so strong. Python has a clone (plotnine) but it lacks several (important) features. In principle you can do nearly as much as in R but especially visualization and data wrangling is much easier in R. Thus, the most famous Python library, pandas, is a <strong>clone</strong> of R.</p>
  
  <p>PSS: <strong>Advanced</strong> statistics aims definitely at R. Python offers a lot of everyday tools and methods for a data scientist but it will never reach those ><strong>13,000</strong> packages R provides. For example, I had to do an inverse regression and python doesn't offer this. In R you can choose between several confidence tests and whether it is linear or nonlinear. 
  The same goes to mixed models: It is implemented in python but it is so basic there I can't realize how this can be sufficient for someone.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-05T11:27:29.797Z
Answers.LastActivityDate: 2019-08-06T13:35:10.263Z
Answers.LastEditDate: 2019-08-06T13:35:10.263Z
Answers.UserDisplayName: Ben
Answers.Body: <p>I would say yes. Python is better than R for most tasks, but R has its niche and you would still want to use it in many circumstances.</p>
  
  <p>Additionally, learning a second language will improve your programming skills.</p>
  
  <p>My own perspective on the strengths of R vs Python is that I would prefer R for a small, single-purpose program involving tables or charts, or exploratory work in the same vein. I would prefer Python for everything else.</p>
  
  <ul>
  <li>R is <strong>really</strong> good for table mashing. If most of what a particular program is going to do is smoosh some tables into different shapes, then R is the thing to pick. Python has tools for this, but R is designed for it and does it better.</li>
  <li>It's worth switching to R whenever you need to make a chart, because <em>ggplot2</em> is a masterpiece of API usability and <em>matplotlib</em> is a crawling horror.</li>
  <li>Python is well designed for general purpose programming. It has a very well designed set of standard data structures, standard libraries, and control flow statements.</li>
  <li>R is poorly suited for general purpose programming. It doesn't handle tree-structured or graph-structured data well. It has some rules (like being able to look into and modify your parent scope) which are immediately convenient, but when used lead to programs that do are hard to grow, modify, or compose.</li>
  <li>R also has some straightforwardly bad things in it. These are mostly just historical leftovers like the three different object systems.</li>
  </ul>
  
  <p>To elaborate more on the last point: computer programming done well is lego where you make your own bricks (functions and modules). </p>
  
  <p>Programs are usually modified and repurposed past their original design. As you build them it is useful to think about which parts might be reused, and to build those part in a general way that will let them plug in to the other bricks.</p>
  
  <p>R encourages you to melt all the bricks together.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-06T12:04:17.830Z
Answers.LastActivityDate: 2019-08-06T12:04:17.830Z
Answers.UserDisplayName: GlennS
Answers.Body: <p>As others have said, it's not a "switch". But is it worth adding Python to your arsenal? I would say certainly. In data science, Python is popular and becoming ever more popular, while R is receding somewhat. And in the fields of machine learning and neural networks, I'd say that Python is the main language now -- I don't think R really comes close here in terms of usage. The reason for all of this is generality. Python is intended as a general programming language, and allows you to easily script all kinds of tasks. If you're staying strictly within a neatly structured statistical world, R is great, but with AI you often end up having to do novel, miscellaneous things, and I don't think R can beat Python at that. And because of this, I think Python and its packages will be receiving more support and development when it comes to the more cutting-edge tech.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-05T11:32:55.813Z
Answers.LastActivityDate: 2019-08-05T11:32:55.813Z
Answers.UserDisplayName: Denziloe
Answers.Body: <blockquote>
    <p>Person who chases two rabbits catches neither</p>
  </blockquote>
  
  <p>And yes, Python is more popular. I work in both but, business speaking, it's easy to find a job on Python than in R.  </p>
  
  <p>So, you could:</p>
  
  <ul>
  <li>Pick Python because it is more popular.   However, you must start from scratch.</li>
  </ul>
  
  <p>Or</p>
  
  <ul>
  <li>Stay with R, after all, you have one year worth of training with R.  But it is not popular.</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-07T15:52:16.820Z
Answers.Text: The suggestion here that learning an additional programming language will somehow leave you worse off is nonsense. Learning additional programming languages, especially those that are unfamiliar, will always improve your skills as a programmer in any language.
Answers.UserDisplayName: Will Da Silva
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-06T12:50:11.093Z
Answers.LastActivityDate: 2019-08-06T12:50:11.093Z
Answers.UserDisplayName: magallanes
Answers.Body: <p>This is totally my personal opinion.</p>
  
  <p>I read in my office (at a construction site) that "There is a right tool for every task."</p>
  
  <p>I expect me to face a variety of tasks, as a programmer. I want as many tools as I can "buy or invest in", as possible. One day one tool will help me solve it, some other day some other tool. R (for statistics) and Python (for in general) are two tools I definitely want with me and I think it is worth investment for me. </p>
  
  <p>As far as switch is concerned, I will use the most efficient tool I know (where efficiency is measured by client's requirement, time and cost investment and ease of coding) . The more tools I know, the merrier! Of course there is a practical limit to it.</p>
  
  <p>All this is my personal opinion and not necessarily correct.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-06T12:02:06.503Z
Answers.LastActivityDate: 2019-08-06T12:02:06.503Z
Answers.UserDisplayName: Amit
Answers.Body: <p>It sounds like you have invested 1 year for data science with R, and embedded into R environment, but want to explore python for data science. </p>
  
  <p>First learn the basics of the python like how lists and tuple works and how classes and objects work.</p>
  
  <p>Then get your hands dirty with some libraries like numpy matplotlib pandas. Learn tensorflow or keras and then go for data science. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-06T11:47:12.527Z
Answers.LastActivityDate: 2019-08-06T21:21:53.977Z
Answers.LastEditDate: 2019-08-06T21:21:53.977Z
Answers.UserDisplayName: Nitish Kumar
Answers.Body: <p>I want to reframe your question.</p>
  
  <p>Don't think about switching, think about adding.</p>
  
  <p>In data science you'll be able to go very far with either python or r but you'll go farthest with both.</p>
  
  <p>Python and r integrate very well, thanks to the <code>reticulate</code> package. I often tidy data in r because it is easier for me, train a model in python to benefit from superior speed and visualize the outcomes in r in beautiful <code>ggplot</code> all in one notebook!</p>
  
  <p>If you already know r there is no sense in abandoning it, use it where sensible and easy to you. But it is 100% a good idea to add python for many uses.</p>
  
  <p>Once you feel comfortable in both you'll have  a workflow that fits you best dominated by your favorite language.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-06T01:13:02.433Z
Answers.Text: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/105238/discussion-on-answer-by-fnguyen-is-a-switch-from-r-to-python-worth-it).
Answers.UserDisplayName: nbro
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-05T08:01:04.957Z
Answers.LastActivityDate: 2019-08-05T08:01:04.957Z
Answers.UserDisplayName: Fnguyen
Body: <p>I just finished a 1-year Data Science master's program where we were taught R. I found that Python is more popular and has a larger community in AI.</p>
  <p>What are the advantages that Python may have over R in terms of features applicable to the field of Data Science and AI (other than popularity and larger community)? What positions in Data Science and AI would be more Python-heavy than R-heavy (especially comparing industry, academic, and government job positions)? In short, is Python worthwhile in all job situations or can I get by with only R in some positions?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-05T14:07:01.553Z
Comments.Text: You can't *switch* yourself to Python. You are not talking about a project you already wrote in R and wants to port it to Python, you are simply asking about learning Python (not forgetting R). Is it worth learning Python? Nowdays it is almost impossible to **not** learn Python if you work with anything related to data handling with a computer...
Comments.UserDisplayName: lvella
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-06T06:59:53.263Z
Comments.Text: It might also be worth mentioning that if you are writing papers or preparing presentations that you would have to compare the tools there. So e.g. in the case of R you would have Sweave or KnitR for static papers or (`beamer` class) presentations and in the case and Jupyter Notebook (formerly IPython Notebook) for dynamic notebooks (which you can also export to TeX).
Comments.UserDisplayName: phk
Tags: <python><comparison><r>
Title: Is a switch from R to Python worth it?
UserDisplayName: ItsMeMario
ThreadText: # Is a switch from R to Python worth it?
  
  (Asked by: username_0 on 2019-08-04)
  
  I just finished a 1-year Data Science master's program where we were taught R. I found that Python is more popular and has a larger community in AI.
  
  What are the advantages that Python may have over R in terms of features applicable to the field of Data Science and AI (other than popularity and larger community)? What positions in Data Science and AI would be more Python-heavy than R-heavy (especially comparing industry, academic, and government job positions)? In short, is Python worthwhile in all job situations or can I get by with only R in some positions?
  
  **Tags:** python, comparison, r
  
  > **Comments:**
  > **username_1**: You can't *switch* yourself to Python. You are not talking about a project you already wrote in R and wants to port it to Python, you are simply asking about learning Python (not forgetting R). Is it worth learning Python? Nowdays it is almost impossible to **not** learn Python if you work with anything related to data handling with a computer...  
  > **username_2**: It might also be worth mentioning that if you are writing papers or preparing presentations that you would have to compare the tools there. So e.g. in the case of R you would have Sweave or KnitR for static papers or (`beamer` class) presentations and in the case and Jupyter Notebook (formerly IPython Notebook) for dynamic notebooks (which you can also export to TeX).  
  
  ---
  
  ## 8 answers
  
  ### Answer by username_13 on 2019-08-05. Score: 67 | Accepted answer
  
  I want to reframe your question.
  
  Don't think about switching, think about adding.
  
  In data science you'll be able to go very far with either python or r but you'll go farthest with both.
  
  Python and r integrate very well, thanks to the `reticulate` package. I often tidy data in r because it is easier for me, train a model in python to benefit from superior speed and visualize the outcomes in r in beautiful `ggplot` all in one notebook!
  
  If you already know r there is no sense in abandoning it, use it where sensible and easy to you. But it is 100% a good idea to add python for many uses.
  
  Once you feel comfortable in both you'll have a workflow that fits you best dominated by your favorite language.
  
  > **Comments:**
  > **username_3**: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/105238/discussion-on-answer-by-username_13-is-a-switch-from-r-to-python-worth-it).  
  
  ---
  
  ### Answer by username_3 on 2019-08-04. Score: 32
  
  Of course, this type of questions username_10 also lead to primarily opinion-based answers. Nonetheless, it is possible to enumerate the strengths and weakness of each language, with respect to machine learning, statistics, and data analysis tasks, which I username_10 try to list below.
  
  ## R
  
  ### Strengths
  
  * R was designed and developed for statisticians and data analysts, so it provides, [out-of-the-box](https://en.wikipedia.org/wiki/Out_of_the_box_(feature)) (that is, they are part of the language itself), features and facilities for statisticians, which are not available in Python, unless you install a related package. For example, the data frame, which Python does not provide, unless you install the famous Python's [`pandas`](https://pandas.pydata.org/) package. There are other examples like matrices, vectors, etc. In Python, there are also similar data structures, but they are more general, so not specifically targeted for statisticians.
  * There are a lot of statistical libraries.
  
  ### Weakness
  
  * Given its purpose, R is mainly used to solve statistical or data analysis problems. However, it can also be used outside of this domain. See, for example, this Quora question: [Is R used outside of statistics and data analysis?](https://qr.ae/TWvefg).
  
  ## Python
  
  ### Strengths
  
  * A lot of people and companies, including Google and Facebook, invest a lot in Python. For example, the main programming language of TensorFlow and PyTorch (two widely used machine learning frameworks) is Python. So, it is very unlikely that Python won't continue to be widely used in machine learning for at least 5-10 more years.
  * The Python community is likely a lot bigger than the R community. In fact, for example, if you look at [Tiobe's index](https://www.tiobe.com/tiobe-index/), Python is placed 3rd, while R is placed 20th.
  * Python is also widely used outside of the statistics or machine learning communities. For example, it is used for web development (see e.g. the Python frameworks Django or Flask).
  * There are a lot of machine learning libraries (e.g. TensorFlow and PyTorch).
  
  ### Weakness
  
  * It does not provide, out-of-the-box, the statistical and data analysis functionalities that R provides, unless you install an appropriate package. This might be a weakness or a strength, depending on your philosophical point of view.
  
  There are other possible advantages and disadvantages of these languages. For example, both languages are dynamic. However, this feature can both be an advantage and a disadvantage (and it is not strictly related to machine learning or statistics), so I did not list it above. I avoided mentioning opinionated language features, such as code readability and learning curve, for obvious reasons (e.g. not all people have the same programming experience).
  
  ## Conclusion
  
  Python is definitely worth learning if you are studying machine learning or statistics. However, it does not mean that you username_10 not use R anymore. R might still be handier for certain tasks.
  
  > **Comments:**
  > **username_4**: It seems like the "out of the box" feature set is irrelevant.  The relevant thing is the availability of packages that do what you want, no?  
  > **username_3**: @username_4 If you do not have access to the internet, this feature is relevant! Furthermore, if a programming language already provides a feature out of the box, you do not have to lose time looking for it.  
  > **username_5**: Considering Python is heavily infested on being 'batteries included', its weakness is not one you encounter often. Especially since there are Python installations in use which *do* have statistical packages included. For data science in particular, [Anaconda](https://www.anaconda.com/distribution/) is quite popular and solves your immediate concern.  
  
  ---
  
  ### Answer by username_6 on 2019-08-05. Score: 6
  
  I didn't have this choice because I was forced to move from R to Python:
  
  It depends on your **environment**: When you are embedded in an **engineer** department, working technical group or something similar than Python is more feasible.
  
  When you are surrounded by **scientists** and especially **statisticians**, stay with R.
  
  PS: R offers keras and tensorflow as well though it is implemented under the hood of python. Only very advanced stuff username_10 make you need Python.
  Though I'm getting more and more used to Python, the synthax in **R is easier**. And though each package has its own, it is somehow consistent while Python is not..
  And ggplot is so strong. Python has a clone (plotnine) but it lacks several (important) features. In principle you can do nearly as much as in R but especially visualization and data wrangling is much easier in R. Thus, the most famous Python library, pandas, is a **clone** of R.
  
  PSS: **Advanced** statistics aims definitely at R. Python offers a lot of everyday tools and methods for a data scientist but it username_10 never reach those >**13,000** packages R provides. For example, I had to do an inverse regression and python doesn't offer this. In R you can choose between several confidence tests and whether it is linear or nonlinear.
  The same goes to mixed models: It is implemented in python but it is so basic there I can't realize how this can be sufficient for someone.
  
  
  ---
  
  ### Answer by username_7 on 2019-08-06. Score: 4
  
  I would say yes. Python is better than R for most tasks, but R has its niche and you would still want to use it in many circumstances.
  
  Additionally, learning a second language username_10 improve your programming skills.
  
  My own perspective on the strengths of R vs Python is that I would prefer R for a small, single-purpose program involving tables or charts, or exploratory work in the same vein. I would prefer Python for everything else.
  
  * R is **really** good for table mashing. If most of what a particular program is going to do is smoosh some tables into different shapes, then R is the thing to pick. Python has tools for this, but R is designed for it and does it better.
  * It's worth switching to R whenever you need to make a chart, because *ggplot2* is a masterpiece of API usability and *matplotlib* is a crawling horror.
  * Python is well designed for general purpose programming. It has a very well designed set of standard data structures, standard libraries, and control flow statements.
  * R is poorly suited for general purpose programming. It doesn't handle tree-structured or graph-structured data well. It has some rules (like being able to look into and modify your parent scope) which are immediately convenient, but when used lead to programs that do are hard to grow, modify, or compose.
  * R also has some straightforwardly bad things in it. These are mostly just historical leftovers like the three different object systems.
  
  To elaborate more on the last point: computer programming done well is lego where you make your own bricks (functions and modules).
  
  Programs are usually modified and repurposed past their original design. As you build them it is useful to think about which parts might be reused, and to build those part in a general way that username_10 let them plug in to the other bricks.
  
  R encourages you to melt all the bricks together.
  
  
  ---
  
  ### Answer by username_8 on 2019-08-05. Score: 1
  
  As others have said, it's not a "switch". But is it worth adding Python to your arsenal? I would say certainly. In data science, Python is popular and becoming ever more popular, while R is receding somewhat. And in the fields of machine learning and neural networks, I'd say that Python is the main language now -- I don't think R really comes close here in terms of usage. The reason for all of this is generality. Python is intended as a general programming language, and allows you to easily script all kinds of tasks. If you're staying strictly within a neatly structured statistical world, R is great, but with AI you often end up having to do novel, miscellaneous things, and I don't think R can beat Python at that. And because of this, I think Python and its packages username_10 be receiving more support and development when it comes to the more cutting-edge tech.
  
  
  ---
  
  ### Answer by username_9 on 2019-08-06. Score: 0
  
  > Person who chases two rabbits catches neither
  
  And yes, Python is more popular. I work in both but, business speaking, it's easy to find a job on Python than in R.
  
  So, you could:
  
  * Pick Python because it is more popular. However, you must start from scratch.
  
  Or
  
  * Stay with R, after all, you have one year worth of training with R. But it is not popular.
  
  > **Comments:**
  > **username_10**: The suggestion here that learning an additional programming language username_10 somehow leave you worse off is nonsense. Learning additional programming languages, especially those that are unfamiliar, username_10 always improve your skills as a programmer in any language.  
  
  ---
  
  ### Answer by username_11 on 2019-08-06. Score: 0
  
  This is totally my personal opinion.
  
  I read in my office (at a construction site) that "There is a right tool for every task."
  
  I expect me to face a variety of tasks, as a programmer. I want as many tools as I can "buy or invest in", as possible. One day one tool username_10 help me solve it, some other day some other tool. R (for statistics) and Python (for in general) are two tools I definitely want with me and I think it is worth investment for me.
  
  As far as switch is concerned, I username_10 use the most efficient tool I know (where efficiency is measured by client's requirement, time and cost investment and ease of coding) . The more tools I know, the merrier! Of course there is a practical limit to it.
  
  All this is my personal opinion and not necessarily correct.
  
  
  ---
  
  ### Answer by username_12 on 2019-08-06. Score: 0
  
  It sounds like you have invested 1 year for data science with R, and embedded into R environment, but want to explore python for data science.
  
  First learn the basics of the python like how lists and tuple works and how classes and objects work.
  
  Then get your hands dirty with some libraries like numpy matplotlib pandas. Learn tensorflow or keras and then go for data science.
  
  
  ---
  
  