I develop quite a bit of R code that I tend to distribute, or let  
other people embed in their software.  One of the things I'd really  
like to do is find a way to load an R library I've developed, and call  
one function with arguments.

Currently, I achieve that by building a separate R client file, which  
reads in the command line arguments, loads the library, and calls the  
main function. The commandLineArgs function below uses commandArgs(),  
and searches the vector for the keys/values to make life easier.

(code available at inside "birdsuite executables" at http://www.broad.mit.edu/science/programs/medical-and-population-genetics/birdsuite/birdsuite-downloads-0)

Example:
---
library (broadgap.utils)
pedigreeFile<-commandLineArg("pedigreeFile", verbose=T)
outPedigreeFile<-commandLineArg("outPedigreeFile", verbose=T)
relabelPedigree(pedigreeFile, outPedigreeFile)
---
called by:

R CMD BATCH --pedigreeFile="foo" --outPedigreeFile="bar"  
example_client.R

What I'd like to do is find a way to achieve the above, but without  
writing the client file, so I can avoid distributing these wrapper  
client files.  While the above works, it's not terribly robust, and a  
user needs to know what they are doing. To make this robust, there  
would have to be a fair bit of work to properly validate arguments,  
and print help files appropriately. Python would be an obvious choice  
for writing CLI's, as it has great CLI support and is easy to  
distribute and build executables.

I've looked at the following options:

RPy (setup is difficult, some users don't even know R, much less being  
capable of the setup required here, which looks like it needs root)
RSPython (same problems as RPy)

These are reasonable for me to use for my own personal fooling around,  
but not for distributing software to 1000's of users.

Rscript looks like it could be a possibility:
 >Rscript -e 'library(broadgap. utils)' -e 'ls()'
character(0)

Unfortunately, it looks like each expression is evaluated separately.  
Is there a way to evaluate multiple expressions in the same  
environment to make the above work?  If so, I could then wrap R in  
whatever language of choice I'd like, and only have to make a user  
install a library.

Are there other options I'm missing?

Thanks for help/input on this.

-Jim Nemesh
	[[alternative HTML version deleted]]


