I am developing a PHP script and want to use R to get the probability of a t-value. This just requires that I issue one R statement and output the result. The problem I am having is that R will accept batch input but I am not sure that it will accept a "one-liner" (i.e., "/usr/local/bin/R qt(.975, 20)" does not work but you get the idea). Is there a way to pass R a one-liner without having to put it into a batch file and submit it to R as a batch job. Regards, Paul Meagher -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
shelling out to R for one command
4 messages · David Firth, Paul Meagher, Dirk Eddelbuettel
On Saturday, Nov 16, 2002, Paul Meagher wrote:
I am developing a PHP script and want to use R to get the probability of a t-value. This just requires that I issue one R statement and output the result. The problem I am having is that R will accept batch input but I am not sure that it will accept a "one-liner" (i.e., "/usr/local/bin/R qt(.975, 20)" does not work but you get the idea). Is there a way to pass R a one-liner without having to put it into a batch file and submit it to R as a batch job.
various possibilities for this using unix redirection
e.g.
david% echo "3+4" | R --slave
[1] 7
One could for example set this up as a shell script "Roneliner",
so that
david% Roneliner "3+4"
[1] 7
Possibly it's more economical also to use arguments
--no-restore --no-save --no-readline --gui=none
in addition to --slave.
David
Regards, Paul Meagher -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- .-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ ._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Is there a way to pass R a one-liner without having to put it into a batch file and submit it to R as a batch job.
David Firth wrote
various possibilities for this using unix redirection e.g. david% echo "3+4" | R --slave [1] 7
This works nicely: echo "q(.975, 20)" | R --slave
One could for example set this up as a shell script "Roneliner", so that david% Roneliner "3+4" [1] 7
Or this: paul% R1 "3+4" [1] 7 BTW, what do you think Roneliner would look like as a shell script?
Possibly it's more economical also to use arguments
--no-restore --no-save --no-readline --gui=none
in addition to --slave.
The most economical startup options would be good to know. My guess would be just --vanilla option? Regards, Paul
David
Regards, Paul Meagher -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- .-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ ._._._._
50 Wood Grove Drive Truro, Nova Scotia B2N-6Y4 1.902.895.9671 www.datavore.com -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Sat, Nov 16, 2002 at 11:34:50PM -0400, Paul Meagher wrote:
BTW, what do you think Roneliner would look like as a shell script?
"There's more than one way to do it". Here's just one: edd at sonny:~> cat /tmp/R1 #!/bin/sh -e echo "$@" | R --slave edd at sonny:~> /tmp/R1 "print(3+4); qnorm(0.5)" [1] 7 [1] 0 Dirk
Prediction is very difficult, especially about the future. -- Niels Bohr -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._