My Thoughts On R As A Programming Language
My first experiences with R came in the summer of 2019. I read An Introduction to Statistical Learning and worked through the labs, which were written in R. My first programming language is MATLAB, although I have primarily used Python since 2016. I had heard R was difficult to learn, but I found it to be intuitive since most of my programming revolves around data manipulation and modeling/testing. Your mileage may vary though. R is very much a language written by statisticians for statisticians. I could see someone coming from a non-statistical programming background being somewhat confused by it.
I actually prefer R for data exploration to Python. I like being able to read in my data and immediately begin plotting paired correlation plots with pairs
and other parts of base graphics. I also love having access to lm
and glm
for linear modeling and all the standard statistical tests without requiring imports. Packages/libraries for more niche statistical applications also seem a little better implemented in R than in Python. In particular, I prefer using tsDyn
in R to statsmodels
in Python when using a vector error correction model. With that said, you can generally find a Python library to suit one’s needs.
Although there is a lot to like about R, I still prefer Python. I prefer manipulating data with pandas
over dplyr
. When it comes to general programming, Python wins easily. I can write the same exact loop or function in both languages, but the Python one will likely require fewer lines and will be more readable. I have been developing a fair amount of mathematical and numerical functions lately and I think NumPy
is both easier to use and faster than R.
Overall, I think R is a great language to know if you are working with data. You just probably want to learn a more general language as well.