我有一个名为script.r
的R脚本:
someVector <- theCommandLineArgument
如何通过命令行R将c("some","vector")
传递给theCommandLineArgument
?
答案 0 :(得分:0)
script.r
的内容:
input <- commandArgs(trailingOnly = TRUE)
print (paste("Sum of arguments = ", sum(as.numeric(input[1:3]))))
print(input[4:5])
终端:
Rscript script.R 1 2 3 Hello World
输出:
[1] "Sum of arguments = 6"
[1] "Hello" "World"