[Rd] Passing R code from webpage

Simon Urbanek simon.urbanek at r-project.org
Sun Feb 17 15:39:11 CET 2013


On Feb 17, 2013, at 9:29 AM, Mike Marchywka wrote:

>> From: simon.urbanek at r-project.org
>> Date: Sun, 17 Feb 2013 09:16:57 -0500
>> To: matevzpavlic at gmail.com
>> CC: r-devel at r-project.org
>> Subject: Re: [Rd] Passing R code from webpage
>> 
>> On Feb 16, 2013, at 6:48 PM, Matevz Pavlic wrote:
>> 
>>> Hi all,
>>> 
>>> Is there a way to pass R code from web page (html file) to do some
>>> statistics and than plot the output in web browser.
>>> 
>>> I am looking forever at this, and cant find a way.
>>> 
>> 
>> Typically this is done by sending an AJAX request to R and display the result (or simple forms if you want to). I use FastRWeb for this - it even has an example on how you create plots and other output. There is also rApache if you are using apache web server.
> 
> Depending on how you want to use it, as others have suggested, there are a lot of approaches. Invoking an "R" process is a bit expensive and
> having a single R server available is much more efficient however for what we were doing the bigger gain was from caching results. That is,
> we have maps by area, say state or zip code, where we can tolerate results a few minutes old. So, we used a custom java server to
> invoke R as part of a general ability to execute bash scripts and then buffer the resulting images in memory. This approach worked well
> but did potentially require starting a new Rprocess for each request. I had always wanted to make use of shared R instances but never
> got around to doing this as the scaling never became relevant. 
> 
> Our interface was something simple, like "http://host/Rscriptname?zip=00000&otherkeys=value"
> 
> which would return an result with appropriate mime type to keep browser happy and have it fit on page ok etc.
> 
> The point is that  anything that can invoke a bash script can invoke R and if  you are concerned about doing this efficiently it is not hard to write a simple java app that listens on a port and can invoke
> R and then do caching to meet your needs if apache etc does not do this easily. 
> 

That's why FastRWeb gives you all the flexibility without the need to write anything: you can use any webserver you want (with CGI or PHP) or you can use the built-in webserver in Rserve if you don't want any dependencies other than R and it still scales fairly well as it supports parallel connections. You don't need to write anything at all as FastRWeb does all the transformation of URL query parameters, forms etc into R function arguments so you just write scripts with one R function - that simple.

Cheers,
Simon


> 
> 
>> 
>> Cheers,
>> Simon
>> 
>> 
>>> Regards,m
>>> 
>>> 
>>> 
>>> --
>>> View this message in context: http://r.789695.n4.nabble.com/Passing-R-code-from-webpage-tp4658800.html
>>> Sent from the R devel mailing list archive at Nabble.com.
>>> 
>>> ______________________________________________
>>> R-devel at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>> 
>>> 
>> 
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> 		 	   		  
> 



More information about the R-devel mailing list