Skip to content

Calling Objective C/Cocoa code from R

7 messages · Guillaume Chapron, Brian Ripley, Simon Urbanek +2 more

#
Hello,

I have a simulation model (command line tool) written in Objective C/ 
Cocoa. I would like to know if it is possible to call it from R and  
get the results into R as well. The documentation explains how to do  
it with C or Fortran, but I have not found anything with Objective C/ 
Cocoa. Has anyone tried do this or do you know an example explaining  
how?

Thanks

Guillaume
#
Hi, I am running CarbonEmacs and calling R from ESS. When I graph  
data  the default device in ESS is X11() and I'd prefer it to call  
quartz() instead. Is there a way that I can do this by default without  
having to specify quartz() prior to running a graph?
Cheers,
Chris

-----------------
Christopher David Desjardins
Ph.D. Student
Quantitative Methods in Education
Department of Educational Psychology
University of  Minnesota
http://blog.lib.umn.edu/desja004/educationalpsychology/
#
See ?options, look at 'device'.

This is getting to be an FAQ ....
On Thu, 12 Mar 2009, Christopher David Desjardins wrote:

            

  
    
#
Guillaume,
On Mar 12, 2009, at 14:35 , Guillaume Chapron wrote:

            
ObjectiveC uses the same ABI as C (it's in fact just a very thin layer  
above C), so you can safely use R's C API. In addition, if you want to  
instantiate ObjC objects and pass messages (without going through  
function calls), you can use one of the ObjC packages around: Cocoa (http://www.rforge.net/Cocoa/ 
  ) or RObjectiveC (http://www.omegahat.org/RObjectiveC/ ).

All of the above assumes that you want to use that tool as a library  
(R supports ObjC in packages out of the box). If you want to just  
invoke it on the command line, you can use the regular system()  
interface.

Cheers,
Simon
#
The easiest way for you, is to put your Sys.setenv command inside a  
file called .Rprofile, locate in the root of your home directory, ie.  
~/.Rprofile

Commands in this file gets run when you start R.

Kasper
On Mar 12, 2009, at 13:29 , Christopher David Desjardins wrote:

            
#
Thanks Kasper and Prof. Brian. Using Sys.setenv in ~/.Rprofile fixed it.
Chris
On Mar 12, 2009, at 8:51 PM, Kasper Daniel Hansen wrote:

            
-----------------
Christopher David Desjardins
Ph.D. Student
Quantitative Methods in Education
Department of Educational Psychology
University of  Minnesota
http://blog.lib.umn.edu/desja004/educationalpsychology/