[R] shelling out to R for one command

David Firth david.firth at nuffield.oxford.ac.uk
Sat Nov 16 11:02:34 CET 2002


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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list