2012-06-27 15:36
浏览 62


Here's the issue:

I am using R to run some statistical analysis. The results of which will eventually be sent to a an embedded swf on the user's client machine.

To do this, I have PHP execute a shell script to run the R program, and I want to retrieve the results of that program so I can parse them in PHP and respond with the appropriate data.

So, it's simply:

$output = shell_exec("R CMD BATCH /home/bitnami/r_script.R");
echo $output;  

But, I receive nothing of course, because R CMD BATCH writes to a file. I've tried redirecting the output in a manner similar to this question which changes my script to

$output = shell_exec('R CMD BATCH /home/bitnami/raschPL.R /dev/tty');
echo $output; 

But what I get on the console is a huge spillout of the source code, and nothing is echoed.

I've also tried this question's solution in my R script.

tl;dr; I need to retrieve the results of an R script in PHP.


图片转代码服务由CSDN问答提供 功能建议


我正在使用 R 进行一些统计分析。 其结果最终将发送到用户客户端计算机上的嵌入式swf。

为此,我让PHP执行一个shell脚本来运行R程序,我想检索该程序的结果,这样我就可以用PHP解析它们并用适当的方式响应 数据。


  $ output = shell_exec(“R CMD BATCH /home/bitnami/r_script.R”);  
echo $输出;  

但是,我当然没有收到任何信息,因为R CMD BATCH写入文件。 我尝试以类似于问题的方式重定向输出将我的脚本更改为

  $ output = shell_exec('R CMD BATCH /home/bitnami/raschPL.R / dev / tty'); 
echo $ output;  


我也尝试过 我的R脚本中的这个问题的解决方案。

TL;博士; 我需要在PHP中检索R脚本的结果。


  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题