running R within matlab
조회 수: 16 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
채택된 답변
Grzegorz Knor
2012년 3월 9일
There is a Rscript command, so you can run it in this way:
!Rscript your_script.r
댓글 수: 3
Grzegorz Knor
2012년 3월 9일
You have to specify the full path to the Rscript program, I suppose that on your machine it would be:
C:\Program Files\R\R-2.14.1\bin\Rscript
So try run in MATLAB:
!C:\Program Files\R\R-2.14.1\bin\Rscript your_script.r
! - execute operating system command
http://www.mathworks.com/help/techdoc/matlab_env/f0-12994.html#f0-38522
Grzegorz Knor
2012년 3월 9일
See also:
http://stackoverflow.com/questions/3412911/difference-between-r-exe-rcmd-exe-rscript-exe-and-rterm-exe
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!