Skip to content

invoking R scripts from a linux shell ?

3 messages · Enrico Curiotto, Itay Furman, Seth Falcon

#
Hello,

I have written perl programs that extract data from a
text file, process them, and create other text files,
which I'd like to apply some statistics too (for
example with R).

I'd like to do it all in once , with a single script.
I'm not familiar with R, I'd like to know if this task
could be accomplished by creating a linux shells that
launches the perl scripts and then "R functions" that
maybe pass back some results to the system like in
this schema:

S ---> Perl
H <-----
E ---> R functions
L <-----
L

Is it possible ?
Where can I get information to do that? (to call R
from a shell, in background)

Are other better way to do that?

Thank you very much!

Enrico.
#
On Thu, 15 Jan 2004, Enrico Curiotto wrote:

            
You could call R in BATCH mode from the perl script using
one of the system interface operators, e.g., "system", or use the 
'Shell' module.

I have also bumped (but didn't try yet) into R-Perl interface 
called RSPerl which might be much more than you what you need.
I think it is under the "Omega" link in the R website. If not
google for RSPerl.

'R --help' will give you pointers to running R in BATCH mode.

	Itay

--------------------------------------------------------------
itayf at fhcrc.org		Fred Hutchinson Cancer Research Center
#
Hi Enrico,

As seen by other posts, there are many ways to accomplish this sort of
thing.  For simple tasks I've often found it easiest to call R from my
script (in my case Python).  I've not used BATCH mode and instead
call R like this:

    R --slave --no-save < script.R

A common setup for me is to have a functions.R file with routines I want
to use and then to generate a small R script from within Python that
sources functions.R and calls the functions with the proper variables as
determined by the script.

HTH,

+ seth