R Compared to MATLAB (or ‘learning a thing or two from your students’)

March 23rd, 2009 | Categories: math software, matlab, Open Source | Tags:

Near the end of last week I was acting as teaching assistant for a MATLAB course and some of the students wanted to know if there were any viable free, open source alternatives to MATLAB.  I duly listed what I considered to be the standard set – Scilab, Octave, SAGE and Python – which are more or less MATLABy depending on your point of view.

One student asked ‘What about R?’ and I had to confess that I didn’t know much about it except that it is used a lot by statisticians and is essentially a free, open source version of S+.  I ventured the opinion that maybe R was too specialised to be considered a general MATLAB alternative with the caveat that I didn’t actually know what I was talking about.

It seems that there is nothing a student likes more than to teach the teacher and so much googling ensued.  I was pointed to a small set of speed comparisons between MATLAB and R for example which includes some matrix operations like finding eigenvalues and generating Toeplitz matrices.  You don’t get much more MATLABy than matrices!  Other articles such as this comparison between various data analysis packages also proved interesting and useful.

So, thanks to a line of questioning from some MATLAB students, I have yet another thing on my to-do list – find out more about R.  What do you think?  Can R replace MATLAB sometimes?

  1. March 23rd, 2009 at 21:18
    Reply | Quote | #1

    Sometimes. But I prefer QTOctave. It’s a front end for Matlab and it’s always run well for me. But for other, I cannot say.

  2. March 23rd, 2009 at 21:50
    Reply | Quote | #2

    R is very much a statistical language. You can use it to do general programming, but R is a strange beast until you get into a statistician’s frame of mind. (Here are some notes I wrote about learning R when coming from more mainstream programming languages.) R has statistical functionality hard to find elsewhere, and lots of statisticians use it (especially in academia, not as much in industry) but hardly anyone outside statistics has ever heard of it.

  3. Dimitris
    March 23rd, 2009 at 23:26
    Reply | Quote | #3

    Well, to paraphrase Ambassador de Sadesky: “Our source was the New York Times”.


    I use both. R is great.

  4. J Meys
    June 2nd, 2010 at 15:44
    Reply | Quote | #4

    I use mainly R. To correct you, R is FAR more than a free copy of S+. Actually, R has a far bigger functionality than S+, and it has a huge library of modelling packages from virtually any kind of field that is remotely busy with modelling, simulating and off course statistics. The focus is on statistics, so you have a multitude of statistical techniques available. BUt I couldn’t find a thing you can do with Matlab that you can’t do with R as efficient, except for the Maple functionality in the Matlab toolkit. I agree with John, R is a strange beast, but that has more to do with the vectorized thinking you need than with the fact it’s focusing on statistics. You cannot compare R with Matlab if you don’t know your way around R. Which is in the end easier to figure out, as there are numerous free resources on R, including everything brought out by the R-core development team. Not one commercial package can say so.

    I could use Matlab too,as R and Matlab are equivalent for quite a number of things. but I have 2 reasons for sticking with R :
    – it’s free, so I can run it on my home computer as well
    – You don’t have to buy one single book to learn or teach it.

  5. Colin T
    February 9th, 2012 at 22:53
    Reply | Quote | #5

    J Meys, I do not know much about R and have only discovered it a little while ago but I do consider myself an expert MATLAB user. One thing I would disagree with you about is buying a book on Matlab. I have never bought and have always considered the online resources of Matlab to be unequaled. If you need to figure out how to do anything in Matlab all you have to do is Google it and chances are after a few clicks you will be taken to a page explaining how to do exactly what you want. I cannot say the same for R, Matlab simply has a much larger user base and more online resources than R.

  6. MySchizoBuddy
    July 27th, 2012 at 01:13
    Reply | Quote | #6

    in year 2011. There were 26 books written on R and sold 20,000 copies in the entire year. Matlab had 27 books written and sold 8500 copies in 2011.

    Clearly more people are interested in R than Matlab. But that can be due to R being free and Matlab being crazy expensive. btw octave sold less than 100 books in 2011.


  7. John M.
    February 15th, 2013 at 06:42
    Reply | Quote | #7

    Matlab appears to have more a general concept, whereas in R you have many packages from different sources. The core packages of R are excellent. Some of the not common packages, are not. In R really shines in statistics, whereas matlab statistic package can handle the most things, it misses some of the “exotic” things.
    The optimization package, the wavelet, the signal processing, the design of experiment package and the outstanding simulink are big advantages over R. These packages have a highly engineering focus and have its price.
    So in the end it dependends, what you need.
    If you you need simulink or some optimization tasks, go with matlab. If you are a statistican, or need some data to be analyzed, R serves you very well.