shell中调用R语言并传入参数的两种步骤

shell中调用R语言并传入参数的两种方法

第一种:

 

Rscript myscript.R

R脚本的输出

 

第二种:

 

R CMD BATCH myscript.R
# Check the output
cat myscript.Rout

调用R脚本的全部控制台log

 

 

传入参数:

在脚本中add

 

args<-commandArgs(TRUE)

然后shell中:

 

 

Rscript myscript.R arg1 arg2 arg3

注意取出来的参数是所有参数连在一起的character

posted @ 2017-03-28 10:49  holy_black_cat  阅读(4881)  评论(0)    收藏  举报