Bonjour,
Je souhaite faire une application en PHP qui utilise R pour réaliser des graphiques et des calculs. Je travail sous windows.
Je n'arrive pas à trouver l'équivalent de la commande
"Rscript my_rscript.R $N" sous windows
J'ai testémais ça ne fonctionne pas.Code:exec('"C:\Program Files\R\R-2.12.2\bin\i386\R.exe" CMD BATCH C:\wamp\www\app\script.R $N')
Quelqu'un peut m'aider?
script RCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 <?php // poorman.php echo "<form action='poorman.php' method='get'>"; echo "Number values to generate: <input type='text' name='N' />"; echo "<input type='submit' />"; echo "</form>"; if(isset($_GET['N'])) { $N = $_GET['N']; // execute R script from shell // this will save a plot at temp.png to the filesystem exec("Rscript my_rscript.R $N"); // return image tag $nocache = rand(); echo("<img src='temp.png?$nocache' />"); } ?>
Code:
1
2
3
4
5
6
7
8
9
10
11 # my_rscript.R args <- commandArgs(TRUE) N <- args[1] x <- rnorm(N,0,1) png(filename="temp.png", width=500, height=500) hist(x, col="lightblue") dev.off()"