Installing R and RApache in XAMPP for Windows

1.6k views Asked by At

How can I get R and RApache installed in XAMPP for Windows?

I'm new to XAMPP, unix, and server environments. I've googled around but can't find much on putting this PHP, XAMPP, Windows and R combination together.

I'm trying to write a webpage that passes variables to R via the PHP exec() function. The eventual user wants ggvis plots on the arguments, so R is necessary.

I'm running XAMPP on Windows 8.1. The base installation works fine, but I'm stuck at passing variables with exec() because I don't have R or RApache installed in my XAMPP environment, although I have R in my Windows environment.

I have tried the rApache installation instructions.

Running 'sudo apt-get install devscripts git' on the shell returns the error

'sudo' is not recognized as an internal or external command, operable program or batch file.'

1

There are 1 answers

0
user5249203 On

The error 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). I don't think it is possible to integrate R, Apache, MySQL, PHP on XAMPP. I am curious myself to learn more if someone have new solutions. However, as you mentioned in the comment, the path to the R script is all that is needed to use exec. Here is a working R script

php/html script

<?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-Script

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")

However, I am interested to know if there are any updated packages from R or modules from php to integrate R and PHP. Any experts who can update on this topic ?