0

lets say i have these files

normal.R

//plot normal distribution from userData
//save image to disk
//return json with filename

controller.php

$functionId = $_GET['functionId']
switch($functionId){
case 1:
//call normal.R with $_POST['userData'] as json
break;
}

ajax.js

$.post('/controller.php?functionId=1,{post:userData},function(data){
//set the src of an specific image to the returned one in the json
})

As you can see i need no interaction with R in the html in the way offered in rApache. I simply want to give json to R and get json from R. Exec scripts ist not supported by webhoster. I also looked into http://cran.r-project.org/doc/FAQ/R-FAQ.html#R-Web-Interfaces but it seems to much for my needs.

Can anybody offer a simple solution?

user3093283
  • 323
  • 1
  • 2
  • 5
  • You might want to check out Shiny: http://www.rstudio.com/shiny/ – James Jan 13 '14 at 17:31
  • Why do you need php. If you install rApache, you can just launch your R script. An example here: http://stackoverflow.com/questions/20851208/whats-the-easiest-way-to-deploy-an-api-incorporating-r-functions. If you really are using php and want to launch an R process. Look at http://stackoverflow.com/questions/4818641/using-r-through-php –  Jan 14 '14 at 08:15
  • hi i spend the whole night with installing ubuntu and rApache. This works exactly as i wanted. But i get one strange error. I cannot create pngs through rApache. Exactly the same code works in r studio and in terminal. The apache error.log says that the cairo DLL failed to load...Does anybody know why this doesnt happen outside from rApache? – user3093283 Jan 14 '14 at 08:26
  • Yes, you need to use a different device driver to create the plots. The best is to create plots with the CairoPNG function from package Cairo instead of using png. Another issue causing your DLL problems might be that you are using a package which is not loaded or installed in the R RApache is using. Make sure you load the package and installed the package correctly (probably using the R installed as root). –  Feb 04 '14 at 10:16

0 Answers0