This question already has an answer here:
- Call R scripts in Matlab 7 answers
I have .m file, using which I want to run a R script. How can I do this.
Matlab File
caller.m %some matlab code % need to call a R script %some matlab code
R script
script.R some R code
I have both the files in the same folder.
How to run script.R from caller.m?
Answer by Drew Steen is in general true, as I found this on most of the places on web. But what worked for me, I am describing below:
Steps:
Append "C:\Program Files\R\R-2.15.3\bin\x64" to "path" variable . This link provides procedure to set path in windows 7 os. Note that bin\x64 instead of bin, bin didn't worked for me.
Restart Matlab.
Use exec=system('Rscript.exe script.R') where the current script.R is in the current directory of matlab.