[R] transfer R objects back to console/command line

2012-05-16 Thread Jannis

Dear R community,


is there any way to invoke R in batch mode, do some calculations and get 
the values of some R variables back into the (bash)shell ? I only 
managed to get some output saved into a text file with:


 R --slave --args 2 2 test.Rtest2.R

test.R contains:

a - as.numeric(commandArgs()[4])
b - as.numeric(commandArgs()[5])

c=a*b


Is ther any way to acess the contents of c in the command line after 
running R ?



Cheers
Jannis

__
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] transfer R objects back to console/command line

2012-05-16 Thread R. Michael Weylandt
Take a look at this SO question:
http://stackoverflow.com/questions/10575005/output-a-boolean-from-an-rscript-into-a-bash-variable

None of the solutions are Boolean specific so you should be good
with them (the key is printing and capturing)

Michael

On Wed, May 16, 2012 at 2:36 PM, Jannis bt_jan...@yahoo.de wrote:
 Dear R community,


 is there any way to invoke R in batch mode, do some calculations and get the
 values of some R variables back into the (bash)shell ? I only managed to get
 some output saved into a text file with:

  R --slave --args 2 2 test.Rtest2.R

 test.R contains:

 a - as.numeric(commandArgs()[4])
 b - as.numeric(commandArgs()[5])

 c=a*b


 Is ther any way to acess the contents of c in the command line after running
 R ?


 Cheers
 Jannis

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

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