At least for me, R by faR. MATLAB has its own way of doing things, which to be honest can probably be defended from many angles. Here are few examples for not so subtle differences between R and MATLAB:

Writing default arguments in MATLAB is exhausting compared to the amazingly trivial Rway of doing it:
1234567891011121314151617181920212223# In Rmysum < function(x,y=2){x+y}mysum(6)[1] 8# Elegant## In MATLABfunction [result] = mysum(x,y)if nargin <2y = 2 ;endresult=x+y ;end>> mysum(6)ans =8# Irritating, especially if you have# many of those you wish to assign defaults to  It is my preference not to clutter the directory with too many files (it is a mess as it is), R lets you write all the functions in one script, say ‘Proj_Functions.R’, then you can source that script and voila*. MATLAB forces each function to have its own file. One can claim it is better organized that way, I prefer to be more compact with my directories.
 MATLAB, in a way, forces you to properly document your function. I often forget the arguments of a function I wrote, in R: type ‘function_name’ of the function to print it to screen to remember what you did, in MATLAB: help ‘function_name’. If you wrote the help section, there you have it, if not, go open the file (though you can relatively quickly do that with: edit ‘function_name’).

R lets you keep on writing your code, while MATLAB forces you to organize it for better readability, see what I mean:
12345678910111213141516#In R this is possible:c(1:10)[1:4][1] 1 2 3 4##In MATLAB this is not possible:[1:10](1:4)% [1:10](1:4)% % Error: Unbalanced or unexpected parenthesis or bracketYou need to:temp = [1:10]temp(1:4) 
Another thing which I find convenient in R and awkward in MATLAB is extracting singular result from a multiple outputs function. For example the function ?dm.test in ‘forecast’ package returns 6 different outputs, including the statistic and p.value. If you only need the p.value, you can use the “$” operator to extract it. In contrast, you need to let MATLAB know that you do not need:
123456temp = dm.test(residuals(f1),residuals(f2),h=1)$p.value# this is not the dm.test function in MATLAB, just an illustration.[~,~,~,p.value] = dm.test(residuals1,residuals2,h)# The "~" sign means to skip this output# until you get to the p.value which is output number 4 in the function 
In MATLAB, you can forget about mixing different kinds of classes in the same matrix, which is a breeze in R, we just use data.frame:
123456mat < data.frame(string=rep('string',2),numeric=c(1,1))matstring numeric1 string 12 string 1
I don’t think this is possible in MATLAB, only workarounds using probably ‘cell’ class.  I like to work slow and to run each line separately, R lets you do that without selecting the line each time, it is enough that the cursor is there.

Printing to screen is well thought of in R, less so in MATLAB:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162### In R# Row Vector:t(c(1:100))[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18][1,] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18[,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35][1,] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35[,36] [,37] [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49] [,50] [,51] [,52][1,] 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52[,53] [,54] [,55] [,56] [,57] [,58] [,59] [,60] [,61] [,62] [,63] [,64] [,65] [,66] [,67] [,68] [,69][1,] 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69[,70] [,71] [,72] [,73] [,74] [,75] [,76] [,77] [,78] [,79] [,80] [,81] [,82] [,83] [,84] [,85] [,86][1,] 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86[,87] [,88] [,89] [,90] [,91] [,92] [,93] [,94] [,95] [,96] [,97] [,98] [,99] [,100][1,] 87 88 89 90 91 92 93 94 95 96 97 98 99 100#Fine# Column Vector:> c(1:100)[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25[26] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50[51] 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75[76] 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100# Elegant#### In MATLAB# Row Vector:>> [1:100]ans =Columns 1 through 201 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20Columns 21 through 4021 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40Columns 41 through 6041 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60Columns 61 through 8061 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80Columns 81 through 10081 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100#ok.. sort of.# Column Vector:[1:100]'12...99100# distasteful
Again, I see the rational behind these delays, shortcuts can cause issues down the road, but perhaps not bad where appropriate, it is a matter of preference.
Got to enjoy the little things eh?
As a final word, I predict that in the future R will simply dominate all other paid competitive software. Think about it, how the hell can these firms compete with the open source community? Thinking about labor productivity, those commercial firms need to be more efficient than the thousands (it will be tens of thousands) programmers that are so passionate to give back, they are working for free. Moving forward, pushing the boundaries, for free. Don’t let it go over your head, see how the workflow is smoothed slowly but surely. From the clunky carriage it used to be to the glistening porsche it is going to be. Work in progress include (but not limited to) Rstudio (Hadley), Knitr (Yihui Xie), Googleivs (Markus). Recently I used some tools that were developed for laymen like myself to be able to make my code public: devtools. The Rteam, talented experienced professionals lubricating those tools to allow the safe service of thousands of packages written to facilitate applications with whatever stateoftheart statistic and econometric techniques you can think of. Books are slowly becoming free as well: a good example is Forecasting: principles and practice which demonstrates the potential of the platform (the book is excellent as expected). Here are some other books posted by Francis Diabold.
Monetary compensation is secondary at best. There are many areas where ‘oldschool’ business plans have to be reconsidered. The future is here, it is just not widely distributed yet (William Gibson). There are (way) too many altruistic selfless professionals giving their time for anyone to stop it.
*You can source few scripts: sapply(FilesToLoad,source,.GlobalEnv).
Yeah, there definitely are some kinks to Matlab (I’d quibble with a few, you can output a structure that has similar functionality as Rs $ and I like the way Matlab labels what columns are stuff when you print ’em). However, it is almost always faster than R at everything. Also, in spite of some of its convenience, there are all sorts of funky kinks to R as well. Python is way better organized. Unfortunately, it can be slower than R at some things unless you spend the effort to speed ’em up.
What about Python? It has an even stronger community and it’s advancing rapidly in data science capabilities.
Pardon, but where is part 2?
https://eranraviv.com/rvsmatlabround2/
Nice points. At least what I find nice in Matlab is debugging and fast plotting
Try python, you won’t need Matlab/R, and you won’t be dissatisfied.
I was a Matlab user, went on to R for a while and now work on Python.
Hi Eran,
nice post. By the way, have you considered using Mathematica?
I’m a big fan of R as well but sometimes I don’t trust the results, specially if I’m using a CRAN package. Mathematica is also more flexible and cheaper than Matlab.
The function definition would simply be:
myFunction[x_,y_:2]:=x+y
You could also get the range directly by:
Range[10][[1;;4]]
and so on.
I program nearly fulltime in Matlab, so I can’t offer an unbiased opinion. While R certainly has a lot of great functionality, I personally find that Matlab is a more productive and pleasant working environment. For an interpreted, rather than a compiled environment. I haven’t found a better one yet.
All your points are welltaken, but overall I can’t imagine switching from Matlab to R, or Python for that matter. For one thing, Matlab’s technical support staff have been a superb resource for me in providing solutions and workarounds. OTOH, my experience with a variety of opensource packages has been that developers and online resources can’t always be relied on to quickly resolve every specific issue.
I agree, Matlabâ€™s technical support service never disappointed me (but nor should it given the price tag). As an aside to your “can’t always be relied on” point, I definitely acknowledge that (but nor should it given the free price tag). The verification needed for open source is the main hurdle for many professionals who find this too cumbersome. I recently found out that Revolution Analytic was acquired by Microsoft, that is a major step in that direction.