[R] export variable from bash to R

sophie melanie.bieli at bluewin.ch
Tue Oct 30 15:03:16 CET 2012


Hi Barry

Thank you very much for your reply. I changed my scripts according to your
suggestions - this is how they look now:

#!/bin/bash

VARIABLES=( a b c d )

for i in ${VARIABLES[@]}; do
      export VARIABLENAME=$i
      Rscript -e 'source("myscript.R")'
done 

and in the R program, I used
args <- Sys.getenv("VARIABLENAME")  instead of args <- commandArgs(TRUE)

But when I add the "R --slave", the program hangs, so I left it out (you
said it was just to cut out the startup messages, so I assumed it shouldn't
really matter). It's still not working, though. There is no error message,
but the R program still doesn't seem to be executed (@Krzysztof: The R
program makes plots - since these plots are not produced,  I figured that
something with the call of myscript.R is not working)

Any ideas or suggestions?




--
View this message in context: http://r.789695.n4.nabble.com/export-variable-from-bash-to-R-tp4647749p4647866.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list