Version 1.4 (4.94 KB) by Wei-Rong Chen
This function calls R to run R script (.r file) under Matlab
Updated 14 Dec 2017

View License

This function calls R to run R script (.r file) under Matlab, and returns 'runR.log' in the same folder with the input R script file.
This code only works in Windows environments. It might work in Mac by modifying 'FindRpath'.
'RscriptFileName' : path + filename of the R script to be run.
'Rpath' (optional) : the path for the installed 'R.exe'. e.g. Rpath = 'C:\Program Files\R\R-3.1.1\bin';
If 'Rpath' is not provided, 'FindRpath' will be executed to automatically find the path for R in Windows Program Files folder.
>> Rpath = 'C:\Program Files\R\R-3.1.1\bin';
>> RscriptFileName = 'D:\test\lmm.R';
>> RunRcode(RscriptFileName, Rpath);
or just >> RunRcode(RscriptFileName);

Cite As

Wei-Rong Chen (2024). RunRcode(RscriptFileName,Rpath) (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on R Language in Help Center and MATLAB Answers
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Dec-14-2017 Support parallel processing (e.g., parfor) (run several R codes simultaneously)

Fixed a bug.

Fixed a bug.