[R] how to source file with arugments

Dieter Menne dieter.menne at menne-biomed.de
Thu Nov 6 08:11:32 CET 2008


Jiqiang Guo <guojq28 <at> gmail.com> writes:

> As we know when we use R to execute a r program we can add arguments like
> '--args p1 p2'.  But when I am sourcing another file, is there a way to set
> up some arguments for the sourced program.  Thanks!
> 

In general, you can use Sys.getenv() and .setenv() to pass parameters from the
command line. 

passw=Sys.getenv("PASSW")

But when sourcing, why not simply use R?

mypass = "secret"
source("myfile.r")

Dieter



More information about the R-help mailing list