从命令行和PHP exec运行时,Rscript的行为会有所不同

时间:2015-02-12 09:44:17

标签: php r ubuntu rscript

你好我用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 ......当我在PHP的Windows机器上运行相同的脚本时,它运行也很完美)

任何人都有任何想法,为什么会这样?

1 个答案:

答案 0 :(得分:0)

感谢您的所有帮助......所以这不是权限问题(我之前已修复过这些问题).......问题是:----通过PHP传递给命令行的命令执行官是 sudo / Rscript /home/xin/Documents/ClassificationApp/ClassificationAllInOne.R“http://localhost/categorisation/public/classification/data/1423746975.json

然而,R收到的论点是“localhost / categorization / public / 1423746975.json2”;

由于某种原因,Ubuntu / PHP组合在参数字符串的末尾添加了一个2 ....我在ClassificationAllInOne.R中添加了一行来剥离2并且它工作得很好