【发布时间】:2017-09-11 23:21:45
【问题描述】:
在使用 R 创建命令行工具时,我决定使用docopt package。它适用于传递标志,但我不知道如何传递两个数值。见以下代码:
#! /usr/bin/Rscript
'usage: ./test.R [-lr <low> -hr <high>]
options:
-h --help Shows this screen
-lr --low <low> Passes low risk investiment
-hr --high <high> Passes high risk investiment' -> doc
library(docopt)
# retrieve the command-line arguments
opts <- docopt(doc)
# what are the options? Note that stripped versions of the parameters are added to the returned list
cat(opts$high)
cat(opts$low)
str(opts)
每当我尝试使用 ./test.R -lr 2000 -hr 4000 运行时,它都会警告我正在加载方法包并且不返回任何其他内容。
- 我的错误是什么?
【问题讨论】: