是否有一个包来处理R中的命令行选项? [英] Is there a package to process command line options in R?

查看:168
本文介绍了是否有一个包来处理R中的命令行选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一个包来处理R中的命令行选项?

Is there a package to process command-line options in R?

我知道 commandArgs ,但它太基本了。其结果基本上等价于 C argc argv >,但是我需要一些东西,就像 C ++ 中的 boost :: program_options code>

I know commandArgs, but it's too basic. Its result is basically the equivalent to argc and argv in C, but I'd need something on top of that, just like boost::program_options in C++, or GetOptions::Long in perl.

特别地,在我想提前指定允许哪些选项,如果用户指定了其他内容,则给出错误消息。

In particular, I'd like to specify in advance what options are allowed and give an error message if the user specifies something else.

调用会是这样(用户选项--width = 32 --file = foo.txt):

The call would be like this (with user options --width=32 --file=foo.txt):

R --vanilla --args --width=32 --file=foo.txt < myscript.R

或者,如果 Rscript used:

or, if Rscript is used:

myscript.R --width=32 --file=foo.txt 

(请不要说,你为什么不自己写它,它不那么难在其他语言你不必须自己写。)

(Please don't say, "why don't you write it yourself, it's not that hard". In other languages you don't have to write it yourself either. :)

推荐答案

getopt for R

getopt for R

这篇关于是否有一个包来处理R中的命令行选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆