I'm new in php and R. My operating system is Ubuntu 14.04.
I use php to Run Rscript
exec("Rscript my_rscript.R $checkbox_input $checkbox_output");
args <- commandArgs(TRUE)
len <- length(args)
all=matrix(0,1,len)
for(i in 1:len)
{
all[1,i]=args[i]
}
goal=args[len]
mydata <- read.csv("/home/user/normdata.csv",header=T)
mydata <- mydata[,c(all)]
n = names(mydata)
temp1=paste(n[!n %in% goal],collapse = " + ")
temp2=paste(goal,"~",temp1)
write.table(temp2,file="/home/user/temp2.txt")
temp3 <-as.formula(temp2)
write.table(temp3,file="/home/user/temp3.txt")
It work fine on the terminal,but I need to run it through php, Because I want to let user choose their input value, So how do I fix this problem?? ( It will fail at temp3 <-as.formula(temp2) ,Maybe rscript can't use as.formula() ??)