[R] [newbie] modules.sourceforge.net and system(...) calls

Tom Roche Tom_Roche at pobox.com
Wed Feb 8 22:56:28 CET 2012


summary: how to write an R script that requires certain 'modules' 
(in the modules.sourceforge.net sense, not the generic sense)?

details:

I'm writing an R script (beginning

#!/usr/bin/env Rscript

) that uses a system call to one of the fine NCO tools

http://nco.sourceforge.net/

to run on a linux cluster that uses the fine Environment Modules
package

http://modules.sourceforge.net/

My script works if I remember to do

$ module add nco

before I run the script; if not, I get

sh: <name of tool/>: command not found

since the Environment Modules setup paths, etc. So I'm wondering,

1 How best to write a script that both sets up the module and runs my R?

  Is there an R package that provides modules.sf.net compatibility,
  so that I can run the whole thing via Rscript? Or should I do a
  shell script that does something like

  module add nco
  R CMD BATCH myscript.r

  Or something completely different?

2 How to catch failure of system(...) calls, so as to fail fast?
  (E.g., in case I try to run the R script without setting up the
  modules first.)

TIA, Tom Roche <Tom_Roche at pobox.com>



More information about the R-help mailing list