从Matlab调用R.

use*_*331 2 macos matlab r

我曾经能够通过系统调用从Matlab调用R:

system('"/usr/bin/R" --no-save < myscript.R')
Run Code Online (Sandbox Code Playgroud)

但是现在,使用Matlab R2012b和R版本3.0.0(2013-04-03) - "Masked Marvel",我在加载库时遇到错误,即使从shell运行它时一切正常.我正在运行MacOSX 10.6.8.

Error in dyn.load(file, DLLpath = DLLpath, ...) : 
unable to load shared object'/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so, 6):
Symbol not found: __gfortran_pow_r8_i4
Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
Expected in: /Applications/MATLAB_R2012b.app/sys/os/maci64/libgfortran.2.dylib
in /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
During startup - Warning message:
   package 'stats' in options("defaultPackages") was not found 
Run Code Online (Sandbox Code Playgroud)

koh*_*ske 8

DYLD_LIBRARY_PATH在调用R脚本之前取消设置环境变量:

>> !/usr/bin/Rscript ms.R
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so, 6): Symbol not found: __gfortran_pow_r8_i4
  Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
  Expected in: /Applications/MATLAB_R2013a.app/sys/os/maci64/libgfortran.2.dylib
 in /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
During startup - Warning message:
package 'stats' in options("defaultPackages") was not found 
Error: could not find function "rnorm"
Execution halted

>> !unset DYLD_LIBRARY_PATH; /usr/bin/Rscript ms.R

Call:
lm(formula = y ~ x)

Coefficients:
(Intercept)            x  
   -0.09727      0.03573  
Run Code Online (Sandbox Code Playgroud)