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

原文地址:https://www.cnblogs.com/awishfullyway/p/6632662.html