MATLAB: How to call functions written in the statistics language, ‘R’, from MATLAB

MATLAB

I have written a program in the statistics language R and I want to call it from MATLAB.

Best Answer

The statistics language, 'R', is not supported in MATLAB; however, the following link contains MATLAB functions on MATLAB Central and File Exchange that may allow communication from MATLAB to R.
Please note that the files on the MATLAB Central File Exchange are not supported by MathWorks. Questions regarding files from the File Exchange should be directed to the author of the file.
A partial work-around would to use 'system'. In that case one uses syntax similar to:
>> filename = 'Example.R';
>> system([ 'R CMD BATCH --vanilla ' filename])
ans = 
0
Please notice the '0' output, it means that the 'system' command executed successfully. The actual number returned in the case of an unsuccessful run will be the defined by the external command (in this case R).
Further documentation about the use of the function 'system' can be found here: