HenrikBengtsson / R.matlab

R package: R.matlab
https://cran.r-project.org/package=R.matlab
86 stars 25 forks source link

Error when executing a one-liner #39

Closed ucb closed 7 years ago

ucb commented 7 years ago

I am trying to do the following evaluate(matlab,"tr = treikon('IDN','e:\\Program Files (x86)\\Thomson Reuters\\Eikon\\X\\Bin');")

The error I am getting is

`Exception:

MatlabException: Failed to evaluate expression 'tr = treikon('IDN','e:\Program Files (x86)\Thomson Reuters\Eikon\X\Bin');'.

at #04. readResult.Matlab(this)

Error: MatlabException: Failed to evaluate expression 'tr = treikon('IDN','e:\Program Files (x86)\Thomson Reuters\Eikon\X\Bin');'.`

Executing the same from Matlab window generates no error. Here's the Matlab installation I am using for testing: `MATLAB Version: 8.6.0.267246 (R2015b) MATLAB License Number: 40537114 Operating System: Microsoft Windows 7 Enterprise Version 6.1 (Build 7601: Service Pack 1) Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) Client VM mixed mode

MATLAB Version 8.6 (R2015b) Data Acquisition Toolbox Version 3.8 (R2015b) Database Toolbox Version 6.0 (R2015b) Datafeed Toolbox Version 5.2 (R2015b) Econometrics Toolbox Version 3.3 (R2015b) Financial Instruments Toolbox Version 2.2 (R2015b) Financial Toolbox Version 5.6 (R2015b) Global Optimization Toolbox Version 3.3.2 (R2015b) Image Processing Toolbox Version 9.3 (R2015b) MATLAB Coder Version 3.0 (R2015b) MATLAB Compiler Version 6.1 (R2015b) MATLAB Compiler SDK Version 6.1 (R2015b) Optimization Toolbox Version 7.3 (R2015b) Spreadsheet Link EX Version 3.2.4 (R2015b) Statistics and Machine Learning Toolbox Version 10.1 (R2015b) Symbolic Math Toolbox Version 6.3 (R2015b)`

Other simple commands, such as res <- evaluate(matlab, "C=1+2;") execute with no issues.

NB: Sorry for strange formatting, I cannot find the symbol triggering it.

HenrikBengtsson commented 7 years ago

Your R call uses the string:

"tr = treikon('IDN','e:\\Program Files (x86)\\Thomson Reuters\\Eikon\\X\\Bin');"

which according to the error message MATLAB sees as:

tr = treikon('IDN','e:\Program Files (x86)\Thomson Reuters\Eikon\X\Bin');'

When you say it works when you cut'n'paste it in manually at the MATLAB prompt, did you really try that latter one with single backslashes? Backslashes are used to escape things, so you really want MATLAB to see e:\\Program ... and not e:\Program ....

To achieve this, you need to use \\\\ on the R end for every \\ you want on the MATLAB end. Alternatively, which is much easier, is to use forward slashes, i.e. 'e:/Program Files (x86)/Thomson Reuters/Eikon/X/Bin' - that should work as is.

HenrikBengtsson commented 7 years ago

I'll be closing - feel free to re-open if needed.