[R] Can R scripts executed in batch mode take a commandline argument?
sharpsteen at mac.com
Thu Oct 16 03:43:20 CEST 2008
On Unix/Linux platforms, you can use the included Rscript utility by adding
the following shebang at the top of your program. Command line arguments can
then be retrieved using the commandArgs function:
args <- commandArgs(trailingOnly = TRUE)
args is now a character vector containing every space delimited text string
that followed your program name when you ran it. trailingOnly is set to TRUE
because the RScript interpreter prepends a few arguments of it's own that
you will probably have no use for.
As I stated earlier, this approach works great on Unix/Linux systems, I
havn't tested it in a Windows environment.
Environmental Resources Engineering
Humboldt State University
View this message in context: http://www.nabble.com/Can-R-scripts-executed-in-batch-mode-take-a-commandline-argument--tp20000914p20005573.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help