[R-SIG-Mac] Call R framework from my own Cocoa app?

Simon Urbanek simon.urbanek at r-project.org
Mon Jun 27 19:12:38 CEST 2005


Hi Demitri,

On Jun 27, 2005, at 12:32 PM, Demitri Muna wrote:

> Is it possible to write a Cocoa application for the gui?

Yes=write Cocoa application for R, no=write Cocoa application for GUI  
(although it's not quite clear what you mean by that).

It is possible to write any GUI in Cocoa for the R framework. The  
current R.app GUI shows how to do it. You may want to 'borrow' the  
REngine Obj-C classes from R.app - they are meant to be application  
independent and in long term should go into the framework.

But we have currently no API to interact with the GUI. You can, of  
course, look at the R.app sources and use the classes we provide, but  
they are not guaranteed to stay as-is (in fact we have some plans for  
major re-structuring). You can also enhance the GUI for your purposes  
using the sources as they are licensed under GPL. We can always use  
experienced Cocoa programmers - they are rather rare so far ;).

Now, in some detail:

> 1 - Send the R commands to (R.app? command line R?) to be displayed  
> on an X11 window (or possibly in R.app?).

You could use AppleScript for R.app to achieve this very easily.

> 2 - Is there a reasonably easy way to call the R framework from my  
> app, create a script internally, and display the result it in my  
> own NSView?

What do you mean by "result"? Text? R graphics? As of text, REngine  
gives you full control over the console, so you're free to use  
whatever you want. As of R graphics, that's more tricky, because you  
will have you write a R device or use the Quartz devices as R.app  
does - look in the R.app sources for details, in principle you could  
use any NSView for that.

Cheers,
Simon



More information about the R-SIG-Mac mailing list