Cannot use setwd and read.csv in php r script
galangwwe opened this issue · comments
I try to make WebApp using php & R . this is my php code:
exec("/usr/bin/Rscript /home/bella/Downloads/htdocs/laut/script.r $N");
$nocache = rand();
echo("<img src='tmp.png?$nocache' />");
And this is my script.r code:
slices <- c(10, 12,4, 16, 8)
lbls <- c("US", "UK", "Australia", "Germany", "France")
png(filename="tmp.png", width=600, height=600)
pie(slices, labels = lbls, main="Pie Chart of Countries")
dev.off()
Everything work fine.
Then, i change slices data and store it in csv. I change script.r code:
setwd("/home/bella/Downloads/DATA")
slices<-read.csv("country.csv",header=T,sep=";",dec=",")
lbls <- c("US", "UK", "Australia", "Germany", "France")
png(filename="tmp.png", width=600, height=600)
pie(as.matrix(slices), labels = lbls, main="Pie Chart of Countries")
dev.off()
I run it, but tmp.png file not updated.
It seem that my R code "setwd" and "read.csv" didn't run.
(i try both script in R and running well)
Why this happen?
I don't see how this relates to the reports package. You don't call it or use any of its functions.
what do you mean? i still can't get data from csv
I mean your question appears to have nothing to do with the reports package I maintain and this is the GitHub repo for that package where you have posted this question. You are asking a general R question. May I suggest posting this question to stackoverflow.