packaging R scripts

One of the tedious sub-tasks necessary for distributing the analysis code I use is to package up the R programs (not really “scripts” as it’s a full-featured language) into something that can be run from the command-line.

R does not have the best interface to this, but I found online at a script to run R programs using #! syntax that uses the R startup sequence to “fool” the interpreter into running your script as part of its initial commands. I tweaked this a bit, to use printf instead of echo and to automatically quit the interpreter after the called script returns, and then checked it into subversion as “runR” in the trunk/R directory.

But how to take my current files of various functions and make them into a “real” executable? What I really need is the equivalent of Python’s optparse, or at least getopt. Time to do some more hunting..

Leave a comment

Your comment

  WordPress version 2.8.4