running R within matlab

65 views (last 30 days)
I was wondering if it is possible to work between matlab and R to plot some data. I have a script in matlab which generates a text file. From this I was wondering if it was possible to open R from within matlab and plot the data from this text file and then return to matlab.
For example, if I save a text file called test.txt, in the path 'E:\', and then define the path of R which in my case will be:
pathR = 'C:\Program Files\R\R-2.14.1\bin\R';
Is it possible to run a script already written in R saved under test1.R (saved in the same directory as test.txt) in R from matlab?

Accepted Answer

Grzegorz Knor
Grzegorz Knor on 9 Mar 2012
There is a Rscript command, so you can run it in this way:
!Rscript your_script.r
  3 Comments
Grzegorz Knor
Grzegorz Knor on 9 Mar 2012
See also:
http://stackoverflow.com/questions/3412911/difference-between-r-exe-rcmd-exe-rscript-exe-and-rterm-exe

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!