One of the things that I did not like about using R was that there was not “easy” way of calling it in a command sort of way. The test part of my R workflow consisted in going into the R environment and setting everything up from scratch. This was a pain (to say the least). Another problem that overly annoyed me was that I could not get to the script arguments. My solution to these and more problems was to use the -e argument of the R command (not good).
Today I find out that I was overworking myself all along. Since R 1.5.X it has something called Rscritp, that allows the execution of R scripts in a “hashbang” sort of way. This saves me the trouble of having to directly execute R for testing. I can now code a script and add a “#!/usr/bin/Rscript” to the header so it can do the “right” thing.
But it does not end there… The arguments can be accessed by using the commandArgs() functions. This is OK, but you still have to do quite a lot of analyzing to get the command line parsing right. If there was only something like getoptparse…. It turns out that someone has already been down this road and was kind enough to make an R package for that. I present to you the getopt package. So now I can parse those arguments in a sane way.
This has made my day :)