Re: [R] R script From PHP

2010-03-23 Thread sanchow

Hello,

I am having the same problem. My webmaster is not ready to install R on the
web server.

Is there a way to run R on a remote linux cluster and POST results from the
remote server to my website?

I am sorry if this is more of a PHP question.

Thank you and Any help appreciated.
S
-- 
View this message in context: 
http://n4.nabble.com/R-script-From-PHP-tp931996p1678627.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] R script From PHP

2010-03-23 Thread Romain Francois


Hello,

You might like the php client to Rserve that is part of the next version 
of Rserve. see http://www.rforge.net/Rserve/svn.html


install the last snapshot, and check the client/php/simple.php file

If you decide to go this way, then I'd suggest you use the 
stats-rosuda-devel mailing list for further questions.


Romain

Le 23/03/10 04:27, sanchow a écrit :

Hello,

I am having the same problem. My webmaster is not ready to install R on the
web server.

Is there a way to run R on a remote linux cluster and POST results from the
remote server to my website?

I am sorry if this is more of a PHP question.

Thank you and Any help appreciated.
S



--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/OIXN : raster images and RImageJ
|- http://tr.im/OcQe : Rcpp 0.7.7
`- http://tr.im/O1wO : highlight 0.1-5

__
R-help@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.


Re: [R] R script From PHP

2009-12-02 Thread Amrit Nandan
I tried calling R from a shell script and it works. This is an example file
rscript.sh

R --no-save  EOT
x-2*pi
print(cbind(x,sin(x)))
quit(no)
EOT

This works perfectly on the Linux machine in which I have logged in via SSH
using the command (./rscript.sh)

I tried running this command using php

html
?php

$output = array();
$$retval = 0;
$a = shell_exec('./rscript.sh'. 21);
//print phpinfo();
print $a;

?
/html

this does not work and gives me this error:

./rscript.sh: line 1: R: command not found

Anybody familiar with this?

On Tue, Dec 1, 2009 at 5:35 PM, Romain Francois
romain.franc...@dbmail.comwrote:

 On 12/01/2009 12:48 PM, Hrishi Mittal wrote:

 Hi Amrit,

 I believe you can you use the PHP system command to call Rscript or R CMD.
 I
 don't know much PHP but this page might be useful -
 http://php.net/manual/en/function.system.php.

 You might also want to look at rapache -
 http://biostat.mc.vanderbilt.edu/rapache/

 Good luck with your project and do post a link to your webpage when you
 get
 it running.


 There is also a simple php client to Rserve in the next version of Rserve.
 http://www.rforge.net/Rserve/index.html

 --
 Romain Francois
 Professional R Enthusiast
 +33(0) 6 28 91 30 30
 http://romainfrancois.blog.free.fr
 |- http://tr.im/FtUu : new package : highlight
 |- http://tr.im/EAD5 : LondonR slides
 `- http://tr.im/BcPw : celebrating R commit #5



[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] R script From PHP

2009-12-02 Thread Romain Francois

On 12/02/2009 10:43 AM, Amrit Nandan wrote:

I tried calling R from a shell script and it works. This is an example
file rscript.sh

R --no-save  EOT
x-2*pi
print(cbind(x,sin(x)))
quit(no)
EOT

This works perfectly on the Linux machine in which I have logged in via
SSH using the command (./rscript.sh)

I tried running this command using php

html
?php

$output = array();
$$retval = 0;
$a = shell_exec('./rscript.sh'. 21);
//print phpinfo();
print $a;

?
/html

this does not work and gives me this error:

./rscript.sh: line 1: R: command not found


Maybe shell_exec('sh ./rscript.sh 21' ) instead, maybe you need to 
have the full path of R.


With this design, you are going to start a new R session each time you 
want anything to be computed, and you are going to have to format the 
result of the R code as a string and parse this string back in php.




You really should look into Rserve and its new php client, which I think 
will solve all of these problems at once.


Just download the version 0.6-1 from here : 
http://www.rforge.net/Rserve/files/


$ wget http://www.rforge.net/src/contrib/Rserve_0.6-1.tar.gz
# R CMD INSTALL Rserve_0.6-1.tar.gz

start the server

$ R CMD Rserve

grab the php client, and include it into your php application

$ tar zxvf Rserve_0.6-1.tar.gz
$ less Rserve/src/client/php/simple.php

If you try this route, be aware that the php client is very new. also 
you probably want to post questions regarding it on this mailing list :

http://mailman.rz.uni-augsburg.de/mailman/listinfo/stats-rosuda-devel

Romain



Anybody familiar with this?

On Tue, Dec 1, 2009 at 5:35 PM, Romain Francois
romain.franc...@dbmail.com mailto:romain.franc...@dbmail.com wrote:

On 12/01/2009 12:48 PM, Hrishi Mittal wrote:

Hi Amrit,

I believe you can you use the PHP system command to call Rscript
or R CMD. I
don't know much PHP but this page might be useful -
http://php.net/manual/en/function.system.php.

You might also want to look at rapache -
http://biostat.mc.vanderbilt.edu/rapache/

Good luck with your project and do post a link to your webpage
when you get
it running.


There is also a simple php client to Rserve in the next version of
Rserve. http://www.rforge.net/Rserve/index.html


--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/FtUu : new package : highlight
|- http://tr.im/EAD5 : LondonR slides
`- http://tr.im/BcPw : celebrating R commit #5

__
R-help@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.


Re: [R] R script From PHP

2009-12-02 Thread Amrit Nandan
RServe looks exciting but the problem is that I am not sure whether I would
be allowed to install anything on the linux server on which I am working.

On Wed, Dec 2, 2009 at 3:40 PM, Romain Francois
romain.franc...@dbmail.comwrote:

 On 12/02/2009 10:43 AM, Amrit Nandan wrote:

 I tried calling R from a shell script and it works. This is an example
 file rscript.sh

 R --no-save  EOT
 x-2*pi
 print(cbind(x,sin(x)))
 quit(no)
 EOT

 This works perfectly on the Linux machine in which I have logged in via
 SSH using the command (./rscript.sh)

 I tried running this command using php

 html
 ?php

 $output = array();
 $$retval = 0;
 $a = shell_exec('./rscript.sh'. 21);
 //print phpinfo();
 print $a;

 ?
 /html

 this does not work and gives me this error:

 ./rscript.sh: line 1: R: command not found


 Maybe shell_exec('sh ./rscript.sh 21' ) instead, maybe you need to have
 the full path of R.

 With this design, you are going to start a new R session each time you want
 anything to be computed, and you are going to have to format the result of
 the R code as a string and parse this string back in php.



 You really should look into Rserve and its new php client, which I think
 will solve all of these problems at once.

 Just download the version 0.6-1 from here :
 http://www.rforge.net/Rserve/files/

 $ wget http://www.rforge.net/src/contrib/Rserve_0.6-1.tar.gz
 # R CMD INSTALL Rserve_0.6-1.tar.gz

 start the server

 $ R CMD Rserve

 grab the php client, and include it into your php application

 $ tar zxvf Rserve_0.6-1.tar.gz
 $ less Rserve/src/client/php/simple.php

 If you try this route, be aware that the php client is very new. also you
 probably want to post questions regarding it on this mailing list :
 http://mailman.rz.uni-augsburg.de/mailman/listinfo/stats-rosuda-devel

 Romain


  Anybody familiar with this?

 On Tue, Dec 1, 2009 at 5:35 PM, Romain Francois
 romain.franc...@dbmail.com mailto:romain.franc...@dbmail.com wrote:

On 12/01/2009 12:48 PM, Hrishi Mittal wrote:

Hi Amrit,

I believe you can you use the PHP system command to call Rscript
or R CMD. I
don't know much PHP but this page might be useful -
http://php.net/manual/en/function.system.php.

You might also want to look at rapache -
http://biostat.mc.vanderbilt.edu/rapache/

Good luck with your project and do post a link to your webpage
when you get
it running.


There is also a simple php client to Rserve in the next version of
Rserve. http://www.rforge.net/Rserve/index.html


 --
 Romain Francois
 Professional R Enthusiast
 +33(0) 6 28 91 30 30
 http://romainfrancois.blog.free.fr
 |- http://tr.im/FtUu : new package : highlight
 |- http://tr.im/EAD5 : LondonR slides
 `- http://tr.im/BcPw : celebrating R commit #5



[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] R script From PHP

2009-12-02 Thread Amrit Nandan
Also I tried out your method, it returns the same error. Another thing, If I
change the top line in rscript.sh to R --slave it just gives me a neat
output. I am not sure why running the shell script directly from within the
same folder is working where as from php it is not recognising R command.

On Wed, Dec 2, 2009 at 3:47 PM, Amrit Nandan amrit.nan...@gmail.com wrote:

 RServe looks exciting but the problem is that I am not sure whether I would
 be allowed to install anything on the linux server on which I am working.


 On Wed, Dec 2, 2009 at 3:40 PM, Romain Francois 
 romain.franc...@dbmail.com wrote:

 On 12/02/2009 10:43 AM, Amrit Nandan wrote:

 I tried calling R from a shell script and it works. This is an example
 file rscript.sh

 R --no-save  EOT
 x-2*pi
 print(cbind(x,sin(x)))
 quit(no)
 EOT

 This works perfectly on the Linux machine in which I have logged in via
 SSH using the command (./rscript.sh)

 I tried running this command using php

 html
 ?php

 $output = array();
 $$retval = 0;
 $a = shell_exec('./rscript.sh'. 21);
 //print phpinfo();
 print $a;

 ?
 /html

 this does not work and gives me this error:

 ./rscript.sh: line 1: R: command not found


 Maybe shell_exec('sh ./rscript.sh 21' ) instead, maybe you need to have
 the full path of R.

 With this design, you are going to start a new R session each time you
 want anything to be computed, and you are going to have to format the result
 of the R code as a string and parse this string back in php.



 You really should look into Rserve and its new php client, which I think
 will solve all of these problems at once.

 Just download the version 0.6-1 from here :
 http://www.rforge.net/Rserve/files/

 $ wget http://www.rforge.net/src/contrib/Rserve_0.6-1.tar.gz
 # R CMD INSTALL Rserve_0.6-1.tar.gz

 start the server

 $ R CMD Rserve

 grab the php client, and include it into your php application

 $ tar zxvf Rserve_0.6-1.tar.gz
 $ less Rserve/src/client/php/simple.php

 If you try this route, be aware that the php client is very new. also you
 probably want to post questions regarding it on this mailing list :
 http://mailman.rz.uni-augsburg.de/mailman/listinfo/stats-rosuda-devel

 Romain


  Anybody familiar with this?

 On Tue, Dec 1, 2009 at 5:35 PM, Romain Francois
 romain.franc...@dbmail.com mailto:romain.franc...@dbmail.com wrote:

On 12/01/2009 12:48 PM, Hrishi Mittal wrote:

Hi Amrit,

I believe you can you use the PHP system command to call Rscript
or R CMD. I
don't know much PHP but this page might be useful -
http://php.net/manual/en/function.system.php.

You might also want to look at rapache -
http://biostat.mc.vanderbilt.edu/rapache/

Good luck with your project and do post a link to your webpage
when you get
it running.


There is also a simple php client to Rserve in the next version of
Rserve. http://www.rforge.net/Rserve/index.html


 --
 Romain Francois
 Professional R Enthusiast
 +33(0) 6 28 91 30 30
 http://romainfrancois.blog.free.fr
 |- http://tr.im/FtUu : new package : highlight
 |- http://tr.im/EAD5 : LondonR slides
 `- http://tr.im/BcPw : celebrating R commit #5




[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] R script From PHP

2009-12-02 Thread Amrit Nandan
Some more development: I found the directory of R in the Root

It is
/usr/bin/R

I did a ls -l R and got this output
-rwxr-xr-x 1 root root 6642 Jan  9  2006 R (This looks like in CHMOD 755
already)

So I modified my shell script

#!/bin/sh
cd /usr/bin/
pwd
R --slave EOF
x-2*pi
print(cbind(x,sin(x)))
quit(no)
EOF

This is returning me the same error when I try to execute it via my PHP
shell_exec('./rscript.sh'. 21);

Error:
/usr/bin ./rscript.sh: line 4: R: command not found

This is really wierd.

On Wed, Dec 2, 2009 at 3:52 PM, Amrit Nandan amrit.nan...@gmail.com wrote:

 Also I tried out your method, it returns the same error. Another thing, If
 I change the top line in rscript.sh to R --slave it just gives me a neat
 output. I am not sure why running the shell script directly from within the
 same folder is working where as from php it is not recognising R command.


 On Wed, Dec 2, 2009 at 3:47 PM, Amrit Nandan amrit.nan...@gmail.comwrote:

 RServe looks exciting but the problem is that I am not sure whether I
 would be allowed to install anything on the linux server on which I am
 working.


 On Wed, Dec 2, 2009 at 3:40 PM, Romain Francois 
 romain.franc...@dbmail.com wrote:

 On 12/02/2009 10:43 AM, Amrit Nandan wrote:

 I tried calling R from a shell script and it works. This is an example
 file rscript.sh

 R --no-save  EOT
 x-2*pi
 print(cbind(x,sin(x)))
 quit(no)
 EOT

 This works perfectly on the Linux machine in which I have logged in via
 SSH using the command (./rscript.sh)

 I tried running this command using php

 html
 ?php

 $output = array();
 $$retval = 0;
 $a = shell_exec('./rscript.sh'. 21);
 //print phpinfo();
 print $a;

 ?
 /html

 this does not work and gives me this error:

 ./rscript.sh: line 1: R: command not found


 Maybe shell_exec('sh ./rscript.sh 21' ) instead, maybe you need to have
 the full path of R.

 With this design, you are going to start a new R session each time you
 want anything to be computed, and you are going to have to format the result
 of the R code as a string and parse this string back in php.



 You really should look into Rserve and its new php client, which I think
 will solve all of these problems at once.

 Just download the version 0.6-1 from here :
 http://www.rforge.net/Rserve/files/

 $ wget http://www.rforge.net/src/contrib/Rserve_0.6-1.tar.gz
 # R CMD INSTALL Rserve_0.6-1.tar.gz

 start the server

 $ R CMD Rserve

 grab the php client, and include it into your php application

 $ tar zxvf Rserve_0.6-1.tar.gz
 $ less Rserve/src/client/php/simple.php

 If you try this route, be aware that the php client is very new. also you
 probably want to post questions regarding it on this mailing list :
 http://mailman.rz.uni-augsburg.de/mailman/listinfo/stats-rosuda-devel

 Romain


  Anybody familiar with this?

 On Tue, Dec 1, 2009 at 5:35 PM, Romain Francois
 romain.franc...@dbmail.com mailto:romain.franc...@dbmail.com wrote:

On 12/01/2009 12:48 PM, Hrishi Mittal wrote:

Hi Amrit,

I believe you can you use the PHP system command to call Rscript
or R CMD. I
don't know much PHP but this page might be useful -
http://php.net/manual/en/function.system.php.

You might also want to look at rapache -
http://biostat.mc.vanderbilt.edu/rapache/

Good luck with your project and do post a link to your webpage
when you get
it running.


There is also a simple php client to Rserve in the next version of
Rserve. http://www.rforge.net/Rserve/index.html


 --
 Romain Francois
 Professional R Enthusiast
 +33(0) 6 28 91 30 30
 http://romainfrancois.blog.free.fr
 |- http://tr.im/FtUu : new package : highlight
 |- http://tr.im/EAD5 : LondonR slides
 `- http://tr.im/BcPw : celebrating R commit #5





[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] R script From PHP

2009-12-02 Thread Hrishi Mittal

I agree with Romain that you should probably try and get Rserve to work as
that is a much better way. However, to get your commandline version working,
I suggest you use the Rscript comman instead of a bash script. So let's say
you save your R script as a myscript.R file. Then do:

shell_exec('Rscript /path/to/myscript.R'. 21);

If that still gives you an error like Rscript command not found, then you
need to make sure your R bin directory is added to the PATH system variable.
-- 
View this message in context: 
http://n4.nabble.com/R-script-From-PHP-tp931996p932992.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] R script From PHP

2009-12-02 Thread Romain Francois

On 12/02/2009 12:30 PM, Hrishi Mittal wrote:



I agree with Romain that you should probably try and get Rserve to work as
that is a much better way. However, to get your commandline version working,
I suggest you use the Rscript comman instead of a bash script. So let's say
you save your R script as a myscript.R file. Then do:

shell_exec('Rscript /path/to/myscript.R'. 21);

If that still gives you an error like Rscript command not found, then you
need to make sure your R bin directory is added to the PATH system variable.


... maybe shell_exec('/usr/bin/Rscript /path/to/myscript.R'. 21);

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/FtUu : new package : highlight
|- http://tr.im/EAD5 : LondonR slides
`- http://tr.im/BcPw : celebrating R commit #5

__
R-help@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.


Re: [R] R script From PHP

2009-12-02 Thread Amrit Nandan
How do I check whether R bin directory is added to PATH variable or not and
if not then how do i add it?

On Wed, Dec 2, 2009 at 5:34 PM, Romain Francois
romain.franc...@dbmail.comwrote:

 On 12/02/2009 12:30 PM, Hrishi Mittal wrote:



 I agree with Romain that you should probably try and get Rserve to work as
 that is a much better way. However, to get your commandline version
 working,
 I suggest you use the Rscript comman instead of a bash script. So let's
 say
 you save your R script as a myscript.R file. Then do:

 shell_exec('Rscript /path/to/myscript.R'. 21);

 If that still gives you an error like Rscript command not found, then you
 need to make sure your R bin directory is added to the PATH system
 variable.


 ... maybe shell_exec('/usr/bin/Rscript /path/to/myscript.R'. 21);


 --
 Romain Francois
 Professional R Enthusiast
 +33(0) 6 28 91 30 30
 http://romainfrancois.blog.free.fr
 |- http://tr.im/FtUu : new package : highlight
 |- http://tr.im/EAD5 : LondonR slides
 `- http://tr.im/BcPw : celebrating R commit #5



[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] R script From PHP

2009-12-01 Thread Marianne Promberger
Amrit Nandan amrit.nan...@gmail.com 01-Dec-09 08:27:
 I have created a web interface to enable analysis for users without having
 much to worry about the stats in the backend. In this particular case I have
 reached a stage where I have finally created two arrays between which I want
 to do an independant samples T Test. I have the arrays ready in a PHP
 script, I was hoping if someone could guide me how to invoke R , pass these
 arrays into it and finally get the ttest results out.

Maybe look at
http://cran.r-project.org/doc/FAQ/R-FAQ.html#R-Web-Interfaces

and littler
http://dirk.eddelbuettel.com/code/littler.html
might come in handy as well.

-- 
Marianne Promberger PhD, King's College London
http://promberger.info
R version 2.10.0 (2009-10-26)
Ubuntu 9.04

__
R-help@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.


Re: [R] R script From PHP

2009-12-01 Thread Hrishi Mittal

Hi Amrit,

I believe you can you use the PHP system command to call Rscript or R CMD. I
don't know much PHP but this page might be useful -
http://php.net/manual/en/function.system.php.

You might also want to look at rapache -
http://biostat.mc.vanderbilt.edu/rapache/

Good luck with your project and do post a link to your webpage when you get
it running.
-- 
View this message in context: 
http://n4.nabble.com/R-script-From-PHP-tp931996p932141.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] R script From PHP

2009-12-01 Thread Romain Francois

On 12/01/2009 12:48 PM, Hrishi Mittal wrote:

Hi Amrit,

I believe you can you use the PHP system command to call Rscript or R CMD. I
don't know much PHP but this page might be useful -
http://php.net/manual/en/function.system.php.

You might also want to look at rapache -
http://biostat.mc.vanderbilt.edu/rapache/

Good luck with your project and do post a link to your webpage when you get
it running.


There is also a simple php client to Rserve in the next version of 
Rserve. http://www.rforge.net/Rserve/index.html


--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/FtUu : new package : highlight
|- http://tr.im/EAD5 : LondonR slides
`- http://tr.im/BcPw : celebrating R commit #5

__
R-help@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.