How to transform or use R code in Matlab

Hello everyone !! I would like to know about i have R code but i want to use this R code in matlab. Do you have method or way to use or transform code R for use in matlab ? I attach file R code. Please help me.

18 件のコメント

Boonanan Lechayakittikorn
Boonanan Lechayakittikorn 2018 年 2 月 12 日
thank you for your advise. But i can to do it please help me
Walter Roberson
Walter Roberson 2018 年 2 月 12 日
Are you using MS Windows? What difficulty do you encounter when you use the File Exchange contribution they mentioned?
Boonanan Lechayakittikorn
Boonanan Lechayakittikorn 2018 年 2 月 12 日
Yes, i use MS windows. i try to use "evalR - Run an R command" but it is error.
Walter Roberson
Walter Roberson 2018 年 2 月 12 日
http://neurochannels.blogspot.ca/2010/05/how-to-run-r-code-in-matlab.html?m=1 has some links. I do not know if those are still available.
Did you install the File Exchange contribution I linked to and add it to your MATLAB path? If you are using a recent version of MATLAB you could also use the Add-On Explorer to install it.
Boonanan Lechayakittikorn
Boonanan Lechayakittikorn 2018 年 2 月 12 日
Thank you so much for help me. I will try it now
Boonanan Lechayakittikorn
Boonanan Lechayakittikorn 2018 年 2 月 12 日
Walter Roberson
Walter Roberson 2018 年 2 月 12 日
The link comes up for me without difficulty.
per isakson
per isakson 2018 年 2 月 12 日
A take away from that link is
9. Caveat (added 6/18/12)
From the comments section:
After using R(D)COM and Matlab R-link for a while, I do not recommend it.
The COM interface has trouble parsing many commands and it is difficult to
debug the code. I recommend using a system command from Matlab as described
in the R Wiki. This also avoids having to install all of the RAndFriends
programs.
See RunRcode(RscriptFileName,Rpath), which uses the Matlab function, system
Boonanan Lechayakittikorn
Boonanan Lechayakittikorn 2018 年 2 月 12 日
thank you Per isakson for help me. I did follow this link https://www.mathworks.com/matlabcentral/fileexchange/50071-runrcode-rscriptfilename-rpath- but it is not show output. Output show in picture
Boonanan Lechayakittikorn
Boonanan Lechayakittikorn 2018 年 2 月 12 日
and show this error
Boonanan Lechayakittikorn
Boonanan Lechayakittikorn 2018 年 2 月 12 日
What does this error (Error using RandStream/subsref Maximum recursion limit of 500 reached.
Error in rng>getCurrentType (line 177) gentype = curr.Type;) mean ?
per isakson
per isakson 2018 年 2 月 12 日
編集済み: per isakson 2018 年 2 月 12 日
  • The last statement, test, in the script, test, causes an infinite loop and the error, I assume.
  • Comment out the lines 1,2,6 and 7 and make a new try. Keep it as simple as possible!
per isakson
per isakson 2018 年 2 月 12 日
Did you look for
C:\users\Admin\Desktop\runR.log
?
Boonanan Lechayakittikorn
Boonanan Lechayakittikorn 2018 年 2 月 12 日
編集済み: Boonanan Lechayakittikorn 2018 年 2 月 12 日
I edit follow your suggest but I got error pls help me
per isakson
per isakson 2018 年 2 月 12 日
編集済み: per isakson 2018 年 2 月 12 日
Why did you add "runR.log" ?
I wanted to know if a file named, "runR.log", had been created.
Boonanan Lechayakittikorn
Boonanan Lechayakittikorn 2018 年 2 月 12 日
Sorry,i change function in R and run in matlab and I got output error
<<
>>
per isakson
per isakson 2018 年 2 月 12 日
編集済み: per isakson 2018 年 2 月 12 日
  • Did you read the help text of RunRcode ? I guess not and propose that you do that.
function RunRcode(RscriptFileName,Rpath)
% 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 [...]
  • RunRcode does not return any output arguments. Why did you add A= ?

サインインしてコメントする。

回答 (1 件)

Suryaansh Mata
Suryaansh Mata 2019 年 6 月 18 日

0 投票

TLDR: No, there is not inbuilt functionality to convert R code to MATLAB code
No, MATLAB and R are essentially two different programming languages and there does not exist any inbuilt utility in either MATLAB or R to convert the Coder from one to another.
There might exist any external utility or hard coded converter that does the job, one such utility can be found here which can be given a try https://www.mathworks.com/matlabcentral/fileexchange/5051-matlab-r-link
Note-: There exist inbuilt MATLAB products that can convert MATLAB code to C/C++ or static and dynamic libraries and executables. Search for MATLAB Coder or the 'codegen' command.

カテゴリ

製品

回答済み:

2019 年 6 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by