r-Rscript在从命令行和PHP执行程序运行时表现不同


r - Rscript behaving differently when run from commandline and from PHP exec

嗨,我正在用PHP exec运行一个Rscript,它的行为很奇怪。。。。。。。它启动R,但在以下行抛出错误:-

filein = filein[,c("id","bank","trans_date","description","description_2",
                 "description_3","description_4","description_5" ,"type",
                 "debit","credit","statement_balance", "cleared_balance",
                 "debit_int_rate","credit_int_rate","category")]

这种简单的方法可以重新排列数据集中的列。

它抛出以下错误:-

错误

[.data.frame`(filein, , c("id", "bank", "trans_date", "description", 
:  undefined columns selected

然而,我从命令行运行相同的脚本,它运行时没有任何错误。

(我在带有PHP5的ubuntu 14.04机器上运行Rscript……当我在windows机器上从PHP运行相同的脚本时,它也能完美运行)

有人知道为什么会这样吗?

感谢您的帮助。。。。所以这不是权限问题(我之前已经解决了这些问题)。。。。。。。问题是:----PHP exec传递到命令行的命令是sudo/Rscript/home/xin/Documents/ClassificationApp/ClassificationAllInOne.R"http://localhost/categorisation/public/classification/data/1423746975.json"

然而,R收到的论点是"localhost/categorisation/public/1423746975.json2";

出于某种原因,Ubuntu/PHP组合在参数字符串的末尾添加了一个2。。。。我在ClassificationAllInOne.R中添加了一行来去掉2,它完美地工作了