1

如何在 XAMPP for Windows 中安装 R 和 RApache?

我是 XAMPP、unix 和服务器环境的新手。我用谷歌搜索,但找不到太多关于将这个 PHP、XAMPP、Windows 和 R 组合在一起的信息。

我正在尝试编写一个通过 PHPexec()函数将变量传递给 R 的网页。最终用户想要ggvis关于参数的绘图,因此 R 是必要的。

我在 Windows 8.1 上运行 XAMPP。基本安装工作正常,但我坚持传递变量,exec()因为我没有R或没有RApache安装在我的 XAMPP 环境中,尽管我在我的 Windows 环境中有 R。

我已经尝试了rApache 安装说明

'sudo apt-get install devscripts git'在 shell 上运行 返回错误

'sudo' 不是内部或外部命令、可运行程序或批处理文件。

4

1 回答 1

0

错误sudo is not recognized as an internal or external command, operable program or batch file is because, you are trying to run Linux command on window shell ( command prompt)。我认为不可能在 XAMPP 上集成 R、Apache、MySQL、PHP。如果有人有新的解决方案,我很想了解更多。但是,正如您在评论中提到的,R 脚本的路径就是使用exec. 这是一个有效的 R 脚本

php/html 脚本

<?php
error_reporting(E_ALL & ~E_NOTICE);
if(isset($_GET['N']))   {
  $N = $_GET['N'];    
exec("\"C:\\Program Files\\R\\R-3.2.3\\bin\\Rscript.exe\"
      C:\\my_folder\\www\\R-scripts\\Test.R $N", $output);
echo '<pre>', join("\r\n", $output), "</pre>\r\n";
  $nocache = rand();
  echo("<img src='temp.png?$nocache' />");
}

$out .= "
<form method='get'>
   Number values to generate: <input type='text' name='N' />
   <input type='submit' />
</form>";
echo $out;

R脚本

args <- commandArgs(TRUE)
N <- args[1]
x <- rnorm(N,0,1)
print(x)
png(filename = "temp.png", width=500, height=500)
hist(x, col = "lightblue")

但是,我很想知道是否有任何来自 R 的更新包或来自 php 的模块来集成 R 和 PHP。任何可以更新这个主题的专家?

于 2016-04-21T18:27:39.173 回答