Best way to build an application based on R?
I'm looking for suggestions on how to go about building an application that uses R
for analytics, table generation, and plotting. What I have in mind is an application that:
- displays various data tables in different tabs, somewhat like in Excel, and the columns should be sortable by clicking.
- takes user input parameters in some dialog windows.
- displays plots dynamically (i.e. user-input-dependent) either in a tab or in a new pop-up window/frame
Note that I am not talking about a general-purpose fron-end/GUI for exploring data with R
(like say Rattle
), but a specific application.
Some questions I'd like to see addressed are:
- Is an entirely R-based approach even possible ( on Windows ) ? The following passage from the
Rattle
article inR
-Journal intrigues me:
It is interesting to note that the first implementation of Rattle actually used Python for implementing the callbacks and R for the statistics, using
rpy
. The release ofRGtk开发者_Python百科2
allowed the interface el- ements ofRattle
to be written directly in R so thatRattle
is a fully R-based application
If it's better to use another language for the GUI part, which language is best suited for this? I'm looking for a language where it's relatively "painless" to build the GUI, and that also integrates very well with
R
. From this StackOverflow question How should I do rapid GUI development for R and Octave methods (possibly with Python)? I see thatPython
+PyQt4
+QtDesigner
+RPy2
seems to be the best combo. Is that the consensus ?Anyone have pointers to specific (open source) applications of the type I describe, as examples that I can learn from?
There are lots of ways to do this, including the python approach you mention. If you want to do it solely within R and if your aims are modest enough, the gWidgets package can be used. This exposes some of the features of either RGtk2, tcltk or qtbase (see the qtinterfaces project on r-forge) in a manner that is about as painless as can be. If you want more, look at using those packages directly. I'd recommend RGtk2 if you are going to share with others and if not, qtbase or tcltk.
Python + Qt4 + RPy = Much Win.
For example, see what Carson Farmer has done with Qgis and the ManageR plugin - its a full R interface to geographic data in the Qgis mapping package.
Depending on how much statistical functionality you need you might even get away without needing it at all, doing all the stats in Python, leveraging such goodies as the Numpy numeric package and the Qwt plotting canvas.
How about traditional LAMP + a R backend? Optionally s/MySQL/Postgres and optionally s/PHP/Perl Rapache looks pretty cool too: rapache.net
If you go for C++, take a look at rcpp and Rinside
Java can be combined with R using JRI
RServe gives you a TCP/IP protocol to interact with R. There's a Java client and a C++ client, so either of them can be used.
On a sidenote: Another thing you should be aware of, is that R contains quite some libraries written in Fortran and C, that can be called directly. Same goes for more advanced packages like VGAM, they also contain quite some C routines. Depending on what exactly you want to do, you might try to work with those ones, just to avoid the overhead of the R functions itself.
I've been looking for an overview of those myself, but AFAIK you'll have to do some effort to get everything. Some things you certainly should look at is The R language definition and R Internals.
精彩评论