R can be used also as a scripting tool. We just need to add shebang in the first line of a file (script):
and then the R code should follow.
Often we want to pass arguments to such a script, which can be collected in the script by the commandArgs() function. Then we need to parse the arguments and conditional on them do something. I came with a rather general way of parsing these arguments using simply these few lines:
## Collect arguments args <- a="" href="http://inside-r.org/r-doc/base/commandArgs" style="color: #b81909; text-decoration: none;">commandArgs->
## ... your code here ...Created by Pretty R at inside-R.org
It is some work, but I find it pretty neat and use it for quite a while now. I do wonder what others have come up for this task. I hope I did not miss some very general solution.