//poorman.php
<?php
echo "<form action='poorman.php' method='get'>";
echo "Number values to generate: <input type='text' name='N' />";
echo "<input type='submit' />";
echo "</form>";
if(isset($_GET['N']))
{
$N = $_GET['N'];
// execute R script from shell
// this will save a plot at temp.png to the filesystem
exec(".\R\R-3.1.3\bin\Rscript .\R\R-3.1.3\bin\my_rscript.R $N");
// return image tag
$nocache = rand();
echo("<img src='temp.png?$nocache' />");
}
?>
//my_rscript.R
args <- commandArgs(TRUE)
N <- args[1]
x <- rnorm(N,0,1)
png(filename="temp.png", width=500, height=500)
hist(x, col="lightblue")
dev.off()
This is a simple programe in which r script is included in php and run in localhost.But i wanted to run this code in linux server so how it is possible can anyone explain me please..?