[R-SIG-Mac] Interacting with R GUI app from another Cocoa app

Guillaume Chapron carnivorescience at gmail.com
Sun Nov 29 16:29:57 CET 2009


Hello,

I have a standalone simulation model written in Objective C/Cocoa. Once the simulations are done, I would like to send the output (a large C array) to R.app for further analysis and plotting. I'm able to launch R.app from a Cocoa app by this:

	[[NSWorkspace sharedWorkspace] launchApplication:@"R.app"];

But I'm not able to send the C array or in fact any kind of instructions. I have tried a modified code:

	NSBundle *bundle = [NSBundle bundleWithPath:@"/Applications/R.app"]; 
	NSString *path = [bundle executablePath];
	NSTask *task = [[NSTask alloc] init];
	
	[task setLaunchPath:path];
	[task setArguments:[NSArray arrayWithObject:@"2+3"]];
	[task launch];

But it seems that R.app does not understand the arguments of the NSTask. How from my Cocoa app, can I tell R.app to read a pointer to a C array and convert it to a R object, and how can I send R instructions?

Before I wrote the Objective C model as a dyn library and I could call it from R and run the simulations, but because simulations last hours, I cannot use R.app during that time, so I'm trying to do the reverse, interact with R from a Cocoa app once the simulations are done. Has anyone done something like that?

Thanks for any help!

Guillaume



More information about the R-SIG-Mac mailing list