I'm trying to integrate an R script in PHP to show a graphic. For this I used the example given in this site http://www.r-bloggers.com/integrating-php-and-r/ and it works.
After some adjustments, I tested my code in the browser, but nothing happened. But if i test it in the IDE Geany code it works fine.
Does anyone have any idea what is going on? And how can I solve this problem?
This is my R code:
args <- commandArgs(TRUE)
n=as.integer(args[1]);
library(gdata);
casa=setwd("/var/www")
fpath = file.path(casa, "Azevedo_JAM_final.xls");
dados = read.xls(fpath, header=F);
#(irrelevant code to the problem)
png(filename="medias.png", width=800, height=800)
barplot(df$vmedia, main="Medias", names.arg=df$vlabels,cex.names=0.6,las=2)
dev.off();
This my php code
<?php
$N = 2;
exec("Rscript infografics.r $N");
// return image tag
echo("<img src='medias.png?' />");
?>
Thank you
This works fine for me. Cheers!