Search code examples
phphtmlrcalling-convention

Calling R Script from PHP Page


I have a Rscript which I want to call from my PHP page. It saves two plots in a particular location and those are need to be displayed on the browser. The script is running fine in R Studio and plots are being saved at their respective locations. However, no output is being shown on browser.

<?php



exec("C:\Program Files\R\R-3.2.2\bin\Rscript code.R");




?>

<html>
<body>
<img src="C:/EasyPHP-12.1/www/RLinl/myplot1.jpeg">
<br>
<img src="C:\EasyPHP-12.1\www\RLinl\myplot2.jpeg">
<br> 
<img src="C:/EasyPHP-12.1/www/RLinl/myplot3.jpeg">
<br>
</body>
</html>

Is there any problem in this call to the script ? The script uses a dataset and no parameters are required to pass.


Solution

  • <html>
    <body>
    <img src="/RLinl/myplot1.jpeg">
    <br>
    <img src="/RLinl/myplot2.jpeg">
    <br> 
    <img src="/RLinl/myplot3.jpeg">
    <br>
    

    the above code is assuming that your document root is www and the images are being generated from R