A web interface to an R program

30,266

Solution 1

R has its own web server, so you could do the whole thing within R. Then there's no need to bother with choosing a framework, or getting them to talk to each other and so on - just use an R framework:

http://cran.r-project.org/web/packages/Rook/index.html

If you don't like that for performance or other reasons, pretty much any framework will talk to R one way or another, so use what you are familiar with. I'd use Django and either call R via Rpy2 or run an Rserve process, but if you can program in PHP or Java then use a framework based on those languages. If you can't program in anything but R then either learn Python or use Rook.

Solution 2

Rstudio has a new server called Shiny which uses node.js for the UI:

https://github.com/rstudio/shiny-server

Solution 3

Rstudio provides a webinterface for R see http://rstudio.org/docs/server/getting_started

Solution 4

A very convenient way is to combine Rstudio Server and Rook (see the other answers for the links).

Rstudio Server provides a very easy way to setup an R server that can be accessed by anyone inside the network. You'll typically use it to edit and run your script on that server.

Rook allows you to easily create a web interface by mixing html code for text and interaction (like input fields, etc.) and R code. Once your script works, just launch it from within Rstudio Server, and any user (with access) will be able to connect to it, on the same IP as Rstudio Server.

I am using this setup together with googleVis and am very satisfied.

Solution 5

OpenCPU is currently, in my opinion, the most advanced free package for creating stateless (REST) web services in R. Shiny is a great framework, but if you plan to use the free community version, note that it doesn't handle concurrent calls.

Share:
30,266
user1331120
Author by

user1331120

Updated on July 05, 2022

Comments

  • user1331120
    user1331120 almost 2 years

    I have to develop a web interface allowing the user to enter some inputs that will be passed to an Rscript as parameters and return the result to the user.

    I have some questions for someone who have done a similar web interface:

    1. Which web framework to use
    2. What is the easiest way to communicate the web interface and the Rscripts (within the web app architecture)
    3. Should I install R on the server (if yes how to lauch the Rscripts from the web interface)
  • nico
    nico about 12 years
    cool! didn't know RStudio could do that!
  • Konrad Rudolph
    Konrad Rudolph over 8 years
    Maybe I’m lacking imagination but I have no idea how OpenCPU would help me (easily) develop web applications in R. Is it a web framework? If so, it has the worst description page I’ve ever seen.
  • Bastian
    Bastian over 8 years
    OpenCPU exposes R functions as a REST services. It is based on RApache environment, so it supports concurrent connections by design - no problem with multiple users accessing your webservice at the same time. Is also supports SL (Shiny does both thins only in paid version). First you have to create a regular R package (e.g. using RStudio) containing your application: R code, HTML pages, CSS, JS scripts (jQuery, Bootstrap, etc.) and other resources. HTML pages are static (no preprocessing like in ASP.NET) but with the OpenCPU Ajax-based JS library you can modify them easily.
  • Bastian
    Bastian over 8 years
    After the package with your application is ready, you install it the usual way - and that's all. OpenCPU doesn't contain any "widgets" or "fancy stuff" - it's just a way of exposing your applications in the web. It's stable, fast and reliable solution. I'm using it commercially for a long time and have never been disappointed. The only drawback is that one cannot use Java-based packages (like xlsx) due to a very specific Java's fault. Also please note that you'll have to start thinking "RESTfuly" (stateless calls) which is the standard of nowadays, but not trivial (you may have rough start).
  • Bastian
    Bastian over 8 years
    As regards the documentation, well... I think it's a matter of taste :) I've found there everything to start creating my first apps. API describes how to call your code (synchronously) from the outside. JS lib helps you to make your pages more dynamic by querying the server asynchronously and updating the content of a page. With demo apps on GitHub you can learn it by examples. There is also a simple manual which clarifies some important issues (but sometimes it's easier to use Google than searching the page :) ). Some prior experience in creating RESTful services will make things easier.
  • Konrad Rudolph
    Konrad Rudolph over 8 years
    I think the fact that you just gave a better description of its usage in two comments than is easily accessible on the website speaks volumes about the website. Anyway, I think you're right, this is probably what the OP is after.