Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using R with Apache & PHP [closed]

Tags:

php

r

apache

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.

like image 352
Brandon Bertelsen Avatar asked Jan 12 '10 05:01

Brandon Bertelsen


People also ask

Does Apache spark support R?

Overview. SparkR is an R package that provides a light-weight frontend to use Apache Spark from R. In Spark 3.3. 0, SparkR provides a distributed data frame implementation that supports operations like selection, filtering, aggregation etc.

What is Apache R?

TVS Apache RR310 is a sports bike available at a starting price of Rs. 2,64,980 in India. It is available in only 1 variant and 3 colours. The TVS Apache RR310 is powered by 312.2cc BS6 engine which develops a power of 33.52 bhp and a torque of 27.3 Nm.

How do you run an R in Zeppelin?

To run Zeppelin with the R Interpreter, the SPARK_HOME environment variable must be set. The best way to do this is by editing conf/zeppelin-env.sh . If it is not set, the R Interpreter will not be able to interface with Spark. You should also copy conf/zeppelin-site.

What is the difference between SparkR and Sparklyr?

Sparklyr provides a range of functions that allow you to access the Spark tools for transforming/pre-processing data. SparkR is basically a tool for running R on Spark. In order to use SparkR, we just import it into our environment and run our code.


3 Answers

See the R-FAQ:

Two projects use PHP to provide a web interface to R. R_PHP_Online by Steve Chen (though it is unclear if this project is still active) is somewhat similar to the above Rcgi and Rweb. R-php is actively developed by Alfredo Pontillo and Angelo Mineo and provides both a web interface to R and a set of pre-specified analyses that need no R code input.

and this paper: Using R via PHP for Teaching Purposes: R-php

like image 122
rcs Avatar answered Oct 19 '22 16:10

rcs


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.

like image 23
dangerstat Avatar answered Oct 19 '22 16:10

dangerstat


Rserve now has support for php you can find more info at: http://code.google.com/p/rserve-php/

like image 4
kmace Avatar answered Oct 19 '22 17:10

kmace