2015-11-13 121 views
0

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

我是XAMPP,unix和服務器環境的新手。我一直在搜索,但無法找到這個PHP,XAMPP,Windows和R組合在一起。

我想寫一個網頁,通過PHP exec()函數將變量傳遞給R.最終用戶想要在參數上繪製ggvis圖,因此R是必需的。

我在Windows 8.1上運行XAMPP。基本安裝工作正常,但我堅持傳遞變量exec(),因爲我沒有在我的XAMPP環境中安裝RRApache,儘管我的Windows環境中有R。

我試過rApache installation instructions

運行 'sudo apt-get install devscripts git'在殼返回錯誤

「須藤」不被識別爲一個內部或外部的命令,可操作的程序或批處理文件。」

+1

解決了它。 rApache沒有必要。對我的R本地副本(安裝在XAMPP環境之外)的引用現在就足夠了。調用此工作:exec(「\」C:\\ Program Files \\ R \\ R-3.2.2 \\ bin \\ Rscript.exe \「C:\\ xampp \\ htdocs \\ my_rscript.R $ threeb 「) – newbie

回答

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。任何可以更新此主題的專家?