rm(list=ls())
suppressPackageStartupMessages({
library(getopt)
})
# getopt(),是getopt包的函数,需要先按照getopt包
#
# getopt(spec = NULL, opt = commandArgs(TRUE),command = get_Rscript_filename(), usage = FALSE,debug = FALSE)
#
# spec:一个4或5列的矩阵,里面包括了参数信息,前四列是必须的,第五列可选。
start.time <- Sys.time()
print(start.time)
spec <- matrix(
c("dataset", "d", 1, "character","dataset name",
"filepath", "f",1,"character","file folder of data",
'savedir',"s",1,"character","where to save result"
),byrow=TRUE, ncol=5)
opt <- getopt(spec=spec,debug=FALSE)
结果如下
但是这个地方有个错误需要注意
rm(list=ls())
suppressPackageStartupMessages({
library(getopt)
})
# getopt(),是getopt包的函数,需要先按照getopt包
#
# getopt(spec = NULL, opt = commandArgs(TRUE),command = get_Rscript_filename(), usage = FALSE,debug = FALSE)
#
# spec:一个4或5列的矩阵,里面包括了参数信息,前四列是必须的,第五列可选。
start.time <- Sys.time()
print(start.time)
spec <- matrix(
c("dataset", "d", 1, "character","dataset name",
"filepath", "f",1,"character","file folder of data",
'savedir',"s",1,"character","where to save result",
),byrow=TRUE, ncol=5)
opt <- getopt(spec=spec,debug=FALSE)
就是c()最后不能带, 需要删掉,否则报错