[R] About passing parameter to '.R' script file

Roger Bivand Roger.Bivand at nhh.no
Fri Aug 27 13:22:10 CEST 2004

On Fri, 27 Aug 2004, Kishore, Tapake wrote:

> Hi,
> I am trying the 'R' application for generating the data for the uploaded
> '.gpr' file. I have written script file named 'test.R'. Currently i have
> hardcoded the path of uploaded '.gpr' file in the script itself.

Typically, you can write a batch file that sets environment variables, and
then calls R with your script file, accessing the environment variables
from your R script using Sys.getenv(). This means that the values are not
hard-coded in your script - just the environment variable names - and that
the values inserted into the environment variables in your batch file are
accessible within the script as values using the function mentioned.

> I would like to know how to pass a command line parameter to the
> 'test.R' script file, so that i dont have to hardcode the path and
> filename of the '.gpr' files. Also, need to access these parameters
> inside the script file to use the path of the uploaded file. I am using
> below command to invoke the 'R' application by using the 'test.R' script
> file.
> e.g.
> c:\\R\\rw1091\\bin\\R.exe CMD BATCH c:\\R\\rw1091\\bin\\test.R
> Expecting your suggestion on this.
> Thanks in advance.
> Regards,
> Kishore
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no

More information about the R-help mailing list