【发布时间】:2010-11-09 18:27:39
【问题描述】:
在 R 中是否有处理命令行选项的包?
我知道commandArgs,但它太基础了。它的结果基本上相当于C 中的argc 和argv,但我还需要一些东西,就像C++ 中的boost::program_options 或perl 中的GetOptions::Long。
特别是,我想提前指定允许哪些选项,并在用户指定其他内容时给出错误消息。
调用将是这样的(使用用户选项 --width=32 --file=foo.txt):
R --vanilla --args --width=32 --file=foo.txt < myscript.R
或者,如果使用Rscript:
myscript.R --width=32 --file=foo.txt
(请不要说“为什么不自己写呢,没那么难”。在其他语言中你也不必自己写。:)
【问题讨论】:
标签: parsing command-line r options getopt