Skip to Content

calling R from within Matlab

I am trying to run an R script from within Matlab, and I get the
same error as this poster:
Calling R from Matlab

As far as I can tell the situations are the same, except my
system is running LinuxMint (release 14 Nadia, kernel
3.5.0-17-generic) and the solution in that post does not work for
me. Could anyone make a further suggestion? I'm stumped.

Like the poster in the above thread, my call works from a shell but not from within matlab.

r_script.R contains:

foo <- rnorm( 100 )
cat( sd( foo ), '\n' )
cat( mean( foo ), '\n' )

the error message I get within Matlab:

>> system( 'Rscript /tmp/r_script.R' )
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/usr/lib/R/library/stats/libs/stats.so':
  /usr/local/MATLAB/R2013a/sys/os/glnxa64/libgfortran.so.3: version `GFORTRAN_1.4' not found (required by /usr/lib/liblapack.so.3)
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found 
Error: could not find function "rnorm"
Execution halted
 
ans =
 
     1
 
>> !unset DYLD_LIBRARY_PATH; 
>> system( 'Rscript /tmp/r_script.R' )
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/usr/lib/R/library/stats/libs/stats.so':
  /usr/local/MATLAB/R2013a/sys/os/glnxa64/libgfortran.so.3: version `GFORTRAN_1.4' not found (required by /usr/lib/liblapack.so.3)
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found 
Error: could not find function "rnorm"
Execution halted
 
ans =
 
     1