[R-gui] Getting started on R GUIs
Byron Ellis
bellis at hsph.harvard.edu
Thu Dec 18 06:49:12 MET 2003
On Dec 17, 2003, at 5:05 PM, Anthony Berno wrote:
> Hello all,
>
> I'm working on a Microsoft .NET application in which is, in part, an R
> front end. But I'm having a bit of difficulty getting started. I spent
> a
> bit of time writing a package that communicates with the R executable
> using text, but that was a disaster. Information about other methods
> has
> been a little hard to come by.
Thats because 'other methods' are still fairly experimental. S (and R
by extension) were always intended as an interactive environment (as
opposed to the SAS mainframe model) and R generally makes assumptions
about who has control of the event loop that aren't necessarily true.
It was also never intended to be embedded. However, demand in the last
few years has caused some rethinking, especially in event loops and
exception handling but R is also fairly massive so changes take some
time to happen. That said, all is not lost.
>
> I've used the R DCOM interface, and looked at the source code, but it's
> a little obscure, and I"m having a hard time figuring out how it works
> at all. I've successfully written a VB test app that uses this server,
> but I'd rather not do all the .NET -> DCOM interoperability stuff if
> there is a more direct, and possibly higher-performance route to
> accessing R functionality.
>
> So a few extremely basic questions:
>
> - Is the file R.dll the DLL that is most suitable for letting my app
> talk to R?
Yes and no. It is technically possible to directly embed R--I did it a
few years ago for IIRC 1.3.1 to create an Inproc server for R as part
of an experiment involving Internet Explorer (basically, I turned R
into a plugin). That code was actually in production for a while but
proved difficult to maintain (VC++ and the R headers don't get along)
so I dropped development. About the same time Duncan Temple Lang
developed REmbedded which works well enough on UNIX systems, though
you'd have to ask him about Win32 support.
At the moment AFAIK the eventloop situation is in a state of flux while
things are normalized across platforms (to facilitate, for instance,
the development of the Mac GUI) to allow programmers to more easily
embed the R libraries. Right now there is no official way of doing
this, which is why its not documented.
>
> - Assuming this is the case, I can't figure out what the correct header
> file is, or find any description of the entry points to this DLL. Some
> introductory material would be very helpful!
Rinternals.h is the header you're looking for. There is also some stuff
at developer.r-project.org and www.omegahat.org (particularly the
REventloop and SJava packages for your purposes), just remember that
any eventloop thing is subject to massive revision in the next 6 months
or so. :-)
Speaking as someone who considered a .Net interface for a nanosecond,
I'm guessing you're going to have to do some serious wrapper work. The
actual function calls back and forth aren't really all that difficult.
Rather, they're no more difficult than the usual process of calling
back and forth across the managed/unmanaged code boundary in
.Net---tedious but nothing that requires deep thinking. Your big
problem will likely be in memory management and moving _objects_ across
the managed/unmanaged boundary. Since R has its own memory management,
type systems and dispatching mechanisms that are generally incompatible
with the .Net way of doing things you'll have to spend a fair amount of
time and energy managing these relationships (hence, SJava which has
essentially the same difficulty), the simplest solution probably just
providing an interface to the R type system rather than trying to
automagically do the appropriate conversion. DTL has the most
experience with this sort of problem, as author of the SJava, RPython,
RXlispStat and other bridging interfaces.
> And a few more general ones:
>
> - Does the R engine necessarily run in a different process, or can it
> be
> run in the same process as my app?
No, its just been less painful generally speaking. :-)
>
> - What is the fastest possible way to get a large dataset (10 - 100K
> rows) from an application front end into the R engine, and back out
> again?
Lemme guess, pharma? Microarrays perhaps? The depends on where the data
is coming from I guess. If you can a custom library for reading/writing
from your preferred format is probably fastest since you can exercise
more control over memory and whatnot. Writing that in .Net could prove
painful, but maybe not if you've written a nice wrapper.
>
> Thanks for any comments you might have.
>
> -Anthony Berno
>
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-GUI mailing list
> R-SIG-GUI at stat.math.ethz.ch
> https://www.stat.math.ethz.ch/mailman/listinfo/r-sig-gui
>
---
Byron Ellis (bellis at hsph.harvard.edu)
"Oook" -- The Librarian
More information about the R-SIG-GUI
mailing list