以批处理形式提交R脚本到网格
问题描述:
我想向网格提交R作业。我在MGSA_rand.r
保存的主要研发代码在callmgsa.r
我写以批处理形式提交R脚本到网格
print('here')
source('/home/users/pegah/MGSA_rand.r')
mgsalooprand($SGE_TASK_ID,382)
的文件,我使用的文件Rscript.sh
调用工作(与-t
参数我送corrseponding到$SGE_TASK_ID)
R CMD BATCH --no-save callmgsa.r
值
我提交作业是这样的:
qsub -t 1 -cwd -b y -l vf=1000m /home/users/pegah/Rscript.sh
我既没有错误也没有输出。这个工作就像我提交时一样终止,没有任何输出。你可以帮我吗?
谢谢,Pegah
答
变量$SGE_TASK_ID
是一个shelscript变量。用相同的语法在R中调用它是行不通的。你可以做的是用Rscript
代替。从shell脚本调用:
Rscript callmgsa.r $SGE_TASK_ID
在R脚本,您可以赶上的命令行参数,如:
args <- commandArgs(trailingOnly = TRUE)
print('here')
source('/home/users/pegah/MGSA_rand.r')
mgsalooprand(args[1],382)
这应该工作...
你试过RSCRIPT的家当?这是创建脚本的常用方式:http://stackoverflow.com/questions/750786/whats-the-best-way-to-use-r-scripts-on-the-command-line – flodel 2012-02-19 12:12:40
如果$ SGE_TASK_ID是一个环境变量,你需要使用'Sys.getenv(“SGE_TASK_ID”)'在你的R脚本中访问它。 – flodel 2012-02-19 12:38:57