For example if there is file foo.R with following in it.
args = commandArgs()
print(args)
then, when I run it like
$ R foo.R hello
it should print 'hello' on the terminal.
I searched the mainling list and found a very old post that said said
Please give an exact reference so we know what you are referring to.
This is not what is usually meant by 'R shell scripts' (it is an R script,
not a shell script).
that this feature will be implemented soon. I am expecting this has
already been implemented by now.
That is not what commandArgs() is documented to do so you will need to do
something slightly different. But in the development version of R you can
come very close:
gannet% cat foo.R
args <- commandArgs(TRUE)
print(args)
gannet% ~/R/R-devel/bin/Rscript foo.R hello
[1] "hello"
gannet%
and in any recent version of R
gannet% cat foo2.R
args <- commandArgs()
m <- match("--args", args)
print(args[-(1:m)])
gannet% R --slave --args hello < foo2.R
[1] "hello"
If you have a platform and build of R for which it works, there is also
littler (http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/LittleR),
but beware that are restrictions not stated on that page (such as the need
for R built as a shared library, which is not the default).