Hi,

I am looking for the possibility to call R functions from Matlab.  
googling around I found:
http://www.omegahat.org/RMatlab/

The developers say that there's no official Windows or Mac version  
yet. nevertheless i tried.

my first attempt was unsuccessful. doing
R CMD INSTALL RMatlab
said that it didn't find libR.so

since I found a libR.dylib in /Library/Frameworks/R.framework/Versions/ 
2.6/Resources/lib I changed some lines in the configure file in the  
RMatlab folder:
   #if test -r $R_HOME/lib/libR.so ; then
   if test -r $R_HOME/lib/libR.dylib ; then
      R_SHARED_LIB_DIR=$R_HOME/lib
   #elif test -r $R_HOME/bin/libR.so ; then
   elif test -r $R_HOME/bin/libR.dylib ; then
      R_SHARED_LIB_DIR=$R_HOME/bin

Installation appears to work, except of some warnings. I attach the  
output after R CMD INSTALL RMatlab below.
then I run the shell script:
         . /Library/Frameworks/R.framework/Resources/library/RMatlab/scripts/ 
RMatlab.sh

and set the environments (I did it within Matlab but I don't know if  
that's correct; i also tried setting the environment from within the  
bash shell using export):
setenv R_HOME /Library/Frameworks/R.framework/Resources
setenv LD_LIBRARY_PATH $R_HOME/lib

when I try to start RMatlab from Matlab, Matlab crashes:
x = initializeR({'Rmatlab'})

In R when starting library(RMatlab) I get error messages:
Error in dyn.load(file, ...) :
   kann shared library '/Library/Frameworks/R.framework/Resources/ 
library/RMatlab/libs/i386/RMatlab.so' nicht laden:
  dlopen(/Library/Frameworks/R.framework/Resources/library/RMatlab/ 
libs/i386/RMatlab.so, 6): Library not loaded: @loader_path/libeng.dylib
   Referenced from: /Library/Frameworks/R.framework/Resources/library/ 
RMatlab/libs/i386/RMatlab.so
   Reason: no suitable image found.  Did find:
        /usr/local/lib/libeng.dylib: stat() failed with errno=62
Fehler: Laden von Paket/Namensraum für 'RMatlab' fehlgeschlagen

As you might have noticed I am not very experienced other than with  
binary versions, but I RMatlab.so is probably not suited on OS X. I  
considered building a dylib from XCode (following yet another example  
found when googling), but I think I was doing nonsense.
So here's the question: has anyone managed to successfully install  
RMatlab on OS X? If yes how (perhaps I did some mistake hile  
installing)? Or do you know how it would work? any pointers /  
instructions appreciated.

btw, I'm working on OS X 10.5.1 and using R v2.6.

best wishes,
nathan





########Output of R CMD INSTALL RMatlab
* Installing to library '/Library/Frameworks/R.framework/Resources/ 
library'
* Installing *source* package 'RMatlab' ...
checking for mex... /usr/bin/mex
checking for sed... /usr/bin/sed
Looking for mclmcr.h
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
configure: creating ./config.status
config.status: creating inst/scripts/RMatlab.csh
config.status: creating inst/scripts/RMatlab.sh
config.status: creating src/Makefile
Using the following settings

   Mex compiler:               /usr/bin/mex
   Mex extension:              mexmaci
   Mex linker flags:           -Wl,-flat_namespace -undefined suppress  
-bundle
   R shared library directory: /Library/Frameworks/R.framework/ 
Resources/lib
   Installation directory:     /Library/Frameworks/R.framework/ 
Resources/library/RMatlab


*********************************************************

   To set the environment variables to run R from within Matlab
   or vice versa, source the relevant shell script into your shell
   before running Matlab or R

   Bourne or Bash shell:

      . /Library/Frameworks/R.framework/Resources/library/RMatlab/ 
scripts/RMatlab.sh

   Csh or Tcsh shell:

      source /Library/Frameworks/R.framework/Resources/library/RMatlab/ 
scripts/RMatlab.csh

*********************************************************
** libs
** arch - i386
/usr/bin/mex -argcheck -I/Library/Frameworks/R.framework/Resources/ 
include  -L/Library/Frameworks/R.framework/Resources/lib -lR  callR.c  
convert.c
convert.c: In function ‘convertFromRObject’:
convert.c:408: warning: assignment discards qualifiers from pointer  
target type
ld: warning, duplicate dylib /Applications/MATLAB_R2007b/bin/maci/libz. 
1.dylib
/usr/bin/mex -argcheck -I/Library/Frameworks/R.framework/Resources/ 
include  -L/Library/Frameworks/R.framework/Resources/lib -lR   
initializeR.c
ld: warning, duplicate dylib /Applications/MATLAB_R2007b/bin/maci/libz. 
1.dylib
/usr/bin/mex -argcheck -I/Library/Frameworks/R.framework/Resources/ 
include  -L/Library/Frameworks/R.framework/Resources/lib -lR   
callNamedR.c convert.c
convert.c: In function ‘convertFromRObject’:
convert.c:408: warning: assignment discards qualifiers from pointer  
target type
ld: warning, duplicate dylib /Applications/MATLAB_R2007b/bin/maci/libz. 
1.dylib
cp *.mexmaci ../inst/mex
** R
** inst
** help
  >>> Building/Updating help pages for package 'RMatlab'
      Formats: text html latex example
** building package indices ...
* DONE (RMatlab)


--------------------------------
Dr. Nathan Weisz

INSERM - Unité 821
Dynamique cérébrale et cognition
Centre Hospitalier Le Vinatier, Bâtiment 452
95 Boulevard Pinel
69500 Bron, France

Tel: ++33 - (0)4 - 7213 8915
Email: [EMAIL PROTECTED]
Chat-AV: [EMAIL PROTECTED]
Homepage: http://web.mac.com/nathanweisz
Neurotree: http://neurotree.org/neurotree/tree.php?pid=8692

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html




        [[alternative HTML version deleted]]

_______________________________________________
R-SIG-Mac mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-mac

Reply via email to