<p>If you already know how to code in MATLAB then python is more similar to it than R so I would say you will have easier time to transitioning there. </p>

<p>Otherwise, both R and Python are programming languages so you will be able to do all those things in both of them as you can always program your own functions.</p>

<p>The strength of R is that the language has a large following in the research community, which then in turn means that people write a lot of packages that focus on exactly the models that are commonly used in research. For more than two decades academics and statisticians basically helped to develop R so you can now find library for anything there save for really the most cutting edge econometric techniques - and you can bet that the first place where those will get their packages will be R. For most of the things you describe in your post you will have some excellent libraries and they are relatively more easier to estimate with R than with Python. </p>

<p>Python is more of an general purpose programming language which strength is very intuitive syntax. Writing in Python can sometimes feel like writing in pseudo code - its very intuitive and natural. However, since its more general purpose language its not as tailored to statistical analysis as R. You will definitely be able to do all you want to do there but more routine statistical analysis will be a bit more time consuming to code.  </p>

<p>I actually prefer using R for any standard statistical analysis and Python for numerical analysis &amp; machine learning &amp; mining data through web-scraping. </p>

CC BY-SA 4.0
2020-05-26T16:51:20.080Z
Having learned some Matlab after having worked with R (a lot) and Pyhton (less), I disagree on Matlab being more similar to Python than to R. Matlab and R have in common vectorized operations, and that makes coding in both very similar, at least when programming simple numeric analysis algorithms. However, your mileage may vary.
Pere
CC BY-SA 4.0
2020-05-25T12:29:37.593Z
2020-05-26T13:57:33.613Z
2020-05-26T13:57:33.613Z
1muflon1
<p>I would like to add on to the previous post from 1muflon1.    Total agree with the post and I will try not to repeat anything said but I feel there is some additional information that is worth mentioning about both R and Python.   </p>

<p><strong>When it comes to loops</strong></p>

<p>Python is faster than R, when the number of iterations is less than 1000. Below 100 steps, python is up to 8 times faster than R.   However, when you use the R lappy function R will be faster. R programming has language evolve over time.<br>
<a href="https://datascienceplus.com/loops-in-r-and-python-who-is-faster/" rel="nofollow noreferrer">https://datascienceplus.com/loops-in-r-and-python-who-is-faster/</a></p>

<p><strong>Data visualizations and Maps</strong></p>

<p>R provides some basic packages that are installed by default. This includes the graphics package, which contains about 100 functions to create traditional plots. These very simple  functions will allow you to quickly create scatterplots, boxplots, and histograms. This comes in handy for quick data exploration.</p>

<p>Unlike R, Python does not include data visualization tools by default.  However, Python also provides many libraries like Matplotlib and Seaborn for this purpose.
Python now also offers numerous packages which are equivalents of ggplot2 in R. The most commonly used library for data visualization in Python is Matplotlib.   </p>

<p><strong>Geospatial Maps</strong></p>

<p>When it comes to geospatial maps R is the software to use.  As far as mapping capabilities with python, they are a bit limited.  However, python code is used for qgis and arcmap.  It can be very powerful but you need to really, really know the code and what you are doing to be able to take advantage.</p>

<p>At the end of the day both software’s are good but I invite you to ask yourself these questions before you get started. </p>

<ol>
<li>What problems do you want to solve and what tasks do you need to accomplish?</li>
<li>What are the commonly used tools in your field?</li>
<li>What language are your colleagues using?</li>
</ol>

CC BY-SA 4.0
2020-05-25T22:05:57.767Z
Using R's `data.table` for working with large datasets also gets you very far in terms of speed/efficiency.
Kenneth Rios
CC BY-SA 4.0
2020-05-26T09:07:31.383Z
The benchmark article you link suffers from bad programming. R's speed is sensitive to memory pre-allocation (as is any language). By simply pre-allocating the result's `vec` (as is implicitly done by `lapply()`) you will get an immense increase in speed. I'm not sure how this is realised in Python.
thorepet
CC BY-SA 4.0
2020-05-26T10:18:50.577Z
Some reproducible and regularly updated data processing benchmarks for R, Python and others: https://h2oai.github.io/db-benchmark/
Gregory Demin
CC BY-SA 4.0
2020-05-26T13:24:17.337Z
"R provides some basic packages that are installed by default." Python has a lot of basic packages built-in as well, the rest are easily installed and if you really want something complete to start with, there's [Anaconda](https://www.anaconda.com/).
Mast
CC BY-SA 4.0
2020-05-25T13:15:26.537Z
2020-05-26T12:21:57.360Z
2020-05-26T12:21:57.360Z
Mike J
<p>Quick question (but complex answer) : R or Python ? </p>

<p>I work as an economist/Strategist in the finance industry. As I do a lot of presentations, notes-writing, data searching, my programming time is limited but we try to develop “small scale” models to answer economic/finance questions. So, I mainly do standard stuff such as PCA/factor models SVAR with sign restrictions, VECM…I usually use what tools is best suited for the job (if I find replication codes I can adapt for instance), so usually MATLAB for SVARs and factor analysis, Eviews for quick and dirty stuff…</p>

<p>Now, I am looking at Python and R (which I dabbled with a few years go). Python is broader and I could use it for other stuff (like automate boring stuff with a comp or an iPad) but it seems there are fewer pure econometrics packages than in R (did not find anything for SVAR with sign restrictions for instance). I am looking to extract data from the web as well, and although they both seem to be able to do that, Python, seems more suited right ? </p>

<p>I know there is always the possibility of calling one from the other (with like Rpy) but then you need to learn both languages. 
Any advice ? </p>

<p>Thanks! </p>

CC BY-SA 4.0
2020-05-26T12:34:34.540Z
The correct answer is "yes."
Carl Witthoft
<econometrics><software>
R or Python for private sector economist/strategist
user2952666
# R or Python for private sector economist/strategist

(Asked by: username_0 on 2020-05-25)

Quick question (but complex answer) : R or Python ?

I work as an economist/Strategist in the finance industry. As I do a lot of presentations, notes-writing, data searching, my programming time is limited but we try to develop “small scale” models to answer economic/finance questions. So, I mainly do standard stuff such as PCA/factor models SVAR with sign restrictions, VECM…I usually use what tools is best suited for the job (if I find replication codes I can adapt for instance), so usually MATLAB for SVARs and factor analysis, Eviews for quick and dirty stuff…

Now, I am looking at Python and R (which I dabbled with a few years go). Python is broader and I could use it for other stuff (like automate boring stuff with a comp or an iPad) but it seems there are fewer pure econometrics packages than in R (did not find anything for SVAR with sign restrictions for instance). I am looking to extract data from the web as well, and although they both seem to be able to do that, Python, seems more suited right ?

I know there is always the possibility of calling one from the other (with like Rpy) but then you need to learn both languages.
Any advice ?

Thanks!

**Tags:** econometrics, software

> **Comments:**
> **username_1**: The correct answer is "yes."  

---

## 2 answers

### Answer by username_2 on 2020-05-25. Score: 16

If you already know how to code in MATLAB then python is more similar to it than R so I would say you will have easier time to transitioning there.

Otherwise, both R and Python are programming languages so you will be able to do all those things in both of them as you can always program your own functions.

The strength of R is that the language has a large following in the research community, which then in turn means that people write a lot of packages that focus on exactly the models that are commonly used in research. For more than two decades academics and statisticians basically helped to develop R so you can now find library for anything there save for really the most cutting edge econometric techniques - and you can bet that the first place where those will get their packages will be R. For most of the things you describe in your post you will have some excellent libraries and they are relatively more easier to estimate with R than with Python.

Python is more of an general purpose programming language which strength is very intuitive syntax. Writing in Python can sometimes feel like writing in pseudo code - its very intuitive and natural. However, since its more general purpose language its not as tailored to statistical analysis as R. You will definitely be able to do all you want to do there but more routine statistical analysis will be a bit more time consuming to code.

I actually prefer using R for any standard statistical analysis and Python for numerical analysis & machine learning & mining data through web-scraping.

> **Comments:**
> **username_3**: Having learned some Matlab after having worked with R (a lot) and Pyhton (less), I disagree on Matlab being more similar to Python than to R. Matlab and R have in common vectorized operations, and that makes coding in both very similar, at least when programming simple numeric analysis algorithms. However, your mileage may vary.  

---

### Answer by username_4 on 2020-05-25. Score: 6

I would like to add on to the previous post from username_2. Total agree with the post and I will try not to repeat anything said but I feel there is some additional information that is worth mentioning about both R and Python.

**When it comes to loops**

Python is faster than R, when the number of iterations is less than 1000. Below 100 steps, python is up to 8 times faster than R. However, when you use the R lappy function R will be faster. R programming has language evolve over time.  
<https://datascienceplus.com/loops-in-r-and-python-who-is-faster/>

**Data visualizations and Maps**

R provides some basic packages that are installed by default. This includes the graphics package, which contains about 100 functions to create traditional plots. These very simple functions will allow you to quickly create scatterplots, boxplots, and histograms. This comes in handy for quick data exploration.

Unlike R, Python does not include data visualization tools by default. However, Python also provides many libraries like Matplotlib and Seaborn for this purpose.
Python now also offers numerous packages which are equivalents of ggplot2 in R. The most commonly used library for data visualization in Python is Matplotlib.

**Geospatial Maps**

When it comes to geospatial maps R is the software to use. As far as mapping capabilities with python, they are a bit limited. However, python code is used for qgis and arcmap. It can be very powerful but you need to really, really know the code and what you are doing to be able to take advantage.

At the end of the day both software’s are good but I invite you to ask yourself these questions before you get started.

1. What problems do you want to solve and what tasks do you need to accomplish?
2. What are the commonly used tools in your field?
3. What language are your colleagues using?

> **Comments:**
> **username_5**: Using R's `data.table` for working with large datasets also gets you very far in terms of speed/efficiency.  
> **username_6**: The benchmark article you link suffers from bad programming. R's speed is sensitive to memory pre-allocation (as is any language). By simply pre-allocating the result's `vec` (as is implicitly done by `lapply()`) you will get an immense increase in speed. I'm not sure how this is realised in Python.  
> **username_7**: Some reproducible and regularly updated data processing benchmarks for R, Python and others: https://h2oai.github.io/db-benchmark/  
> **username_8**: "R provides some basic packages that are installed by default." Python has a lot of basic packages built-in as well, the rest are easily installed and if you really want something complete to start with, there's [Anaconda](https://www.anaconda.com/).  

---

