R: write a high-quality GUI for an R-project - r

I have written a piece of R-code that performs a numerical computation. Now, I want to implement it into a nice GUI. I know that there are some R-packages, that allow to create GUIs from within R (e.g. gWidgets, RGtk2, ...). However, they seem to be rather limited in the capabilities and complicate to build. So I thought about going the other way round and writing a windowed-program that incorporates my R-code.
Is it possible to write a nice GUI (for example in Visual Basic.NET or Java) that allows to gather some user inputs, call the R-computations and display the results?
I ask for Visual Basic because there is this new R-Open that comes along with Visual Studio which makes me think the two must offer natural ways of collaboration with each other. I also hope that I would be able to compile an exe with it in the end.
Thank you very much for you Help!
Bernd

You can embed R in C++ code. There are examples in the R source code and documentation.
Very briefly, you'll need to build a shared DLL version of R (i.e with the --enable-R-shlib option) from the source code, using the Windows Tools. This is how GUIs like RStudio function.
The R Admin manuals have detailed instructions. The RInside package might make this a bit easier.
With the shared DLL you could probably embed R in other languages (it works for R in Python).

Related

RTools Big Data and Visual Studio

So, I'm working on a big data project which requires importing data into Visual Studio and using Microsoft's R packages, in particular, the RevoScaleR packages. So, this is all well and good. I've written my scripts. What I would like to do is set it up so an end-user (who doesn't know anything about programming or R) can enter a set of parameters/values into my predict() function and see the output on his/her screen through a web interface or GUI/similar.
Any suggestions?
Thanks.
You can achieve this by leveraging Microsoft R Server's Operationalization Features, as this is a general question, please see the guides here:
https://msdn.microsoft.com/en-us/microsoft-r/operationalize/quickstart-publish-web-service

Using R in Apache Spark

There are some options to access R libraries in Spark:
directly using sparkr
using language bindings like rpy2 or rscala
using standalone service like opencpu
It looks like SparkR is quite limited, OpenCPU requires keeping additional service and bindings can have stability issue. Is there something else specific to Spark architecture which make using any solution not easy.
Do you have any experience with integrating R and Spark you can share?
The main language for the project seems like an important factor.
If pyspark is a good way to use Spark for you (meaning that you are accessing Spark from Python) accessing R through rpy2 should not make much difference from using any other Python library with a C-extension.
There exist reports of users doing so (although with occasional questions such as How can I partition pyspark RDDs holding R functions or Can I connect an external (R) process to each pyspark worker during setup)
If R is your main language, helping the SparkR authors with feedback or contributions where you feel there are limitation would be way to go.
If your main language is Scala, rscala should be your first try.
While the combo pyspark + rpy2 would seem the most "established" (as in "uses the oldest and probably most-tried codebase"), this does not necessarily mean that it is the best solution (and young packages can evolve quickly). I'd assess first what is the preferred language for the project and try options from there.

Remote communication with R – How to start with an R GUI client to access R on a remote Server

I tried RInside's Qt example qdensity and really liked it. It was easy to setup and I was surprised how easy it was to understand and modify given that I have virtually no Qt experience. Now I wonder whether it is possible to use RInside with R somewhere on a remote machine.
It seems that I cannot use RInside for this purpose. I wonder whether there is another way of creating a Qt Desktop app, that communicates with R on some server. I got R Studio Server running and I am really happy with it, but it's for the R people. In order to promote my R stuff within our institute also among non-R people I would like to offer a simple, very limited GUI that can do basics things like showin' some graph or starting a R CMD Batch. I also know shiny (and shiny server) and have been actively testing it recently, but I am looking for a simple Desktop client go connect with my server-side R.
Is there a basis to start out with Rserve and Qt?
Any suggestions (where to start, examples, generally bad idea) ???
What are R's capabilities to handle something like this IPC or D-Bus stuff.
Use Qt with C++, and just process the files that you create with R on you're server.
So for example: create the graphic and save in a format that you can load. BMP, PNG etc. Load it to you're GUI.
Also I suggest Qt Creator for GUI design. Its fast and simple. This idea only fits you if you don't want to stay in in R environment.
When I have created programs that process data and calculate things like probabilities and charts, usually use HTML for the interface using PHP and leaving the rest of the processing (for example R scripts) to the server.
For any recent visitor: Take a look at openCPU, it publishes R functions as restful services and does all the marshalling from R data types from and to JSON.

Document/Scripts management for R code

I am looking for a solution that allows me to keep a track of a multitude of R scripts that I create for various projects and purposes. Some scripts are easily tracked to specific projects, whereas others are "convenience" functions created to serve a set of tasks.
Is there a way I can create a central DB and query it to find which scripts match most appropriately?
I could create a system using a DBMS manually, but are users aware of anything in general or specific to R, that comes in the form of a software tool (maybe FOSS) ?
EDIT: Thank you for the responses. My current system is just a set of scripts with comments that allow me to identify their intended task. Though I use StatET with SVN, I would like a search utility along the lines of the "sos" package.
The question
I am looking for a solution that allows me to keep a track of a multitude of R scripts
that I create for various projects and purposes. Some scripts are easily tracked to specific
projects, whereas others are "convenience" functions created to serve a set of tasks.
fails to address the obvious follow-up of why the existing mechanism is not suitable:
Create a local package for each project
Create one or more local packages for local utility functions
Use R's already existing mechanisms for searching, indexing, testing, cross-referencing
And use any revision control system of your liking, local or on the web, to host the code for 1. to 3. above.
Reinventing an RDBMS schema for 1. to 3. is just wrong in my book. But if you must, go ahead and replicate what you can already (mostly) get for free in tested and widely used code.
R comes with several mechanisms for searching for help, most of which naturally use CRAN. Some examples: the sos package, cranberries, crantastic, and rseek. In many cases, these could be adapted to use a local repository (you can find out how to create a local repository in the R manual, which is very easy to do). Otherwise, if you package your scripts and submit them to CRAN, you will naturally have these available to you. I would also highly recommend this presentation on the subject: Creating R Packages, Using CRAN, R-Forge, And Local R Archive Networks And Subversion (SVN) Repositories from Spencer Graves and Sundar Dorai-Raj.
These would require you to put your code in packages, and create documentation, all of which is worth doing anyway. The package documentation turns out to be very useful for both documenting what things do, and helping your find them in the future. You can use roxygen to create this documentation in-line with your code. Also read this related question: Organizing R Source Code.
Alternatively, the help.search() function can be very useful for searching local packages, regardless of whether you have a repository set up.
You'd probably be best working with a version control system. Many can be indexed and be made search-able. At my work, a stack of R, Eclipse, StatET, Subversion and Subclipse works very well for us.

Is R a compiled language?

I can't find it anywhere on the web (and I don't want to install it). Is the R language a compiled language? How fast does it run a pre-written script? Does it do any kind of compilation, or just execute instructions line by line?
In most cases R is an interpreted language that runs in a read-evaluate-print loop. There are numerous extensions to R that are written in other languages like C and Fortran where speed or interfacing with native libraries is helpful.
I've often rewritten R code in C++ and made it run 100x faster. Looping is especially inefficient in R.
R is generally an interpreted language. However, package compiler offers bytecode compilation that can improve performance. You can also call compiled code from R.
In terms of how fast, it depends on what you are trying to do and how you are trying to do it. Some looping operations can be very slow. However, in many cases, with well written code, the performance of R scripting is determined by the speed of the underlying internal C-based libraries and system memory read-write speeds, and so R is about as fast as anything else.

Resources