I have a problem about how to pass php array to Rscript. In my project, I need to use php to call Rscript to run R code. But I want to pass php array as parameters in Rscript.But When I do this. php report error:Array to string conversion!. I don't know to do it . If it can successfully pass the parameter.I still don't know how to read the array paramter in R.Any ideas? Thanks in advance! Here is a example:
#php file
<?php
$ck=["WT1","WT2"];
$tr=["Al1","Al2"];
exec("Rscript getdata.R $ck $tr");
# getdata.R
args <- commandArgs(TRUE)
ck <- args[1]
tr <- args[2]
ckk <- lapply(strsplit(ck,','),as.character)
trr <- lapply(strsplit(tr,','),as.character)
a <- as.dataframe(a=ckk,b=trr)
write.csv(a,file="test.csv")