[R] how to call R in PHP

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Thu Mar 28 05:13:11 CET 2013


While someone around here might know about PHP (I don't h, the fact that you don't know how to call system suggests that you should be asking in a PHP help forum.

Rserve can be used for interactive sessions, but web services usually aren't designed that way, so you probably want to call R with batch arguments the same way you would call it from the command interpreter, but not actually via the command interpreter.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Lauren Zhang <zxj19880912 at yahoo.cn> wrote:

>Hi,
>I met tough problems when calling R in PHP. I have tried several ways,
>but none of them succeed.��
>first of all, I tried Rserve, but I failed to connect to it.
>Then, I tried cmd.exe. I get the result when I use"��R CMD BATCH
>--vanilla..." in cmd, but I have no idea how to call cmd in php.
>I know "system()" is good to call other systems, I triedbut I get no
>result in my html page.
>if you could provide some suggestion or examples, i would appreciate
>your help.
>
>the code in my php is���
>$cmd="R CMD BATCH--vanilla --slave delete.r";
>$res=system($cmd);
>
>the code in the delete.r file is:
>setwd("c://wamp//www//analysis");
>x<-4;
>y<-3;
>z<-x*y;
>sink("125.txt");
>png(file="125.png");
>barplot(z,border="dark blue")
>title(main=list("earning of comparison",font=4));
>plot(x,z);
>dev.off()
>
>	[[alternative HTML version deleted]]
>
>
>
>------------------------------------------------------------------------
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list