tags:

views:

93

answers:

1

Say I want to have a simple web app that takes some user input, performs a quick calculation in some predefined R script, and returns some cool looking graphic with say ggplot. One way to do this would be:

  1. Have PHP accept some input from a web form
  2. Sanitize the user input in PHP
  3. Send the arguments to some pre-written R script using some combination of the PHP exec() command and Rscript
  4. R does some calculations and saves the plot graphic to the server as well as some meta info to a MySQL database
  5. The client can then access their cool new graphic from their web browser

This seems fairly straight forward to me. Thus my question is, what advantages would the rapache package have over the process described?

+2  A: 

First off, rapache is not a package. It's an apache module and a set of conventions, really a system, for creating web applications written in R...

The advantage is speed. The disadvantage is you'd have to write a bunch of R code. Some might disagree with me on that one, though.

Jeff
As always, speed is king. By 'write a bunch of R code' I'm assuming that one would need to have the R script output the HTML, kind of like the PHP echo() command.
stotastic
If you install RApache module with `brew` R package, you can easily incorporate R code within plain HTML code with `<%` and `%>` tags. Google for Jeroen Ooms' tutorials. AJAX is your friend. Don't put the load on the server with PHP if you can do it with JavaScript. AJAX doesn't eliminate PHP from your webapp, but it eliminates page reload, improves interactivity, good look etc.
aL3xa
Great thanks... by the way, are there any 'R groups' which are focused on R + Web Stuff? I would be very interested in trying to create a simple API between R and some PHP CMS like say Drupal.
stotastic
There's the rApache google group, which I would recommend joining. Also I just put the finishing touches on the rApache wiki here: http://wiki.rapache.net/I plan on adding all kinds of educational material there... when I can find the time.
Jeff
very cool, thanks!
stotastic