I have a bunch of R scripts that do some calculations and return a result. I am planning of building a PHP website that the user can actually submit a form where the data gets passed to my R script, processed and then return the result to the PHP and update the interface.
The plan is to have a database so when a user submits a form, the data gets stored in the database so R can read, process the input and then insert the result in the database so PHP can grab it. However, there are 2 problems:
- How do my R script knows that certain values have been stored in the database so it can grab those values and do the processing?
- When my R script finishes processing the data and insert it to mysql db, how do I get PHP to understand that at this moment PHP needs to query the database and grab the value?
Let's say my R script is like the following:
range<-1:20
m<-mean(range)
s<-sum(range)
print(m)
print(s)
As you can see the input at this case would be 1
and 20
to define the range, and the output is to show the values of m
and s
on my webpage.
Any idea how to accomplish that? thanks!