有时需要反复执行一段R代码,并使用不同得参数,可以将代码用文本编辑器写为R脚本(*.R),在第一行加入

Args <- commandArgs()

然后通过

Rscript *.R 参数1 参数2 ...

执行脚本。

脚本中

Args[6]==参数1

Args[7]==参数2

...

***********************************分割线**********************************
输出commandArgs()可以看到前五个分别是:
[1] "/opt/blc/genome/biosoft/R/lib64/R/bin/exec/R" #这个是R路径
[2] "--slave"                                    
[3] "--no-restore"                               
[4] "--file=test.r"                              
[5] "--args"

所以第一个参数从Args[6]开始

**************************************************************************

转自:http://xiexiaqu.blogbus.com/logs/63029457.html

相关文章:

  • 2021-11-28
  • 2022-12-23
  • 2021-08-27
  • 2021-11-28
  • 2021-11-28
  • 2021-07-07
  • 2022-12-23
  • 2021-11-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案