Is there anyway to run R scripts through Apache and PHP? I would like to be able to pass variables from PHP to R.
Has anyone done something like this?
Essentially, I would like to know if there is a method for passing variables from PHP to R on an apache server.
Personally we used the R CMD BATCH interface to R to achieve this. It’s not very elegant, but essentially we have a user pasting data into a form which is passed to PhP which generates a .R file with something
x = c(1,2,3,4);
dev.off();
plot(x);
Then we get PhP to do an exec “R CMD BATCH “
In the directory you should then get Rplots.ps file which can be served to the client. Equally you can use the jpeg() function to return a jpeg picture of the graphic which can then be displayed on the web page PhP returns.
Not elegant at all, but it works for us.