I want to run a script in R over a page in PHP (Apache server). I can perform simple scripts but when I want to call the R script for the libraries. I plan to run scripts in R and its libraries from a PHP page.
Asked
Active
Viewed 242 times
0
-
Please read the info about [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and how to produce a [minimal reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). At this moment your question is formulated too broad, so be more specific. This will make it much easier for others to help you. – Jaap Jul 07 '14 at 13:17
-
Thank you. The next time I'll be more specific – Sérgio Oliveira Jul 07 '14 at 13:31
2 Answers
0
The proper way to achieve this is by creating APIs in R, and then call those API to fetch data from R server

Shahzad Malik
- 541
- 4
- 6
0
I call the file to be run by PHP.
shell_exec("Rscript /Users/scocosta/Documents/PHP/_my_rscript.R");
My code in R is this.
x<-20
write(x, "/Users/scocosta/Documents/PHP/mistas.txt", sep = "\t")
dev.off()
So it works fine
But I want to do scripts that need to use libraries. For example, the library(e1071). The problem is when I put the script in R a library, do not know why the script does not run in R.

Sérgio Oliveira
- 21
- 2