使R退出非零状态代码

Set*_*jmp 56 r exit

我正在寻找R /等效的linux/POSIX exit(n),它将使用退出代码n停止进程,向父进程发出错误信号.R有这样的设施吗?

Jos*_*ich 62

这是一个论据quit().见?quit.

参数:

status: the (numerical) error status to be returned to the operating
        system, where relevant.  Conventionally ‘0’ indicates
        successful completion.
Run Code Online (Sandbox Code Playgroud)

细节:

 Some error statuses are used by R itself.  The default error
 handler for non-interactive use effectively calls ‘q("no", 1,
 FALSE)’ and returns error code 1.  Error status 2 is used for R
 ‘suicide’, that is a catastrophic failure, and other small numbers
 are used by specific ports for initialization failures.  It is
 recommended that users choose statuses of 10 or more.
Run Code Online (Sandbox Code Playgroud)

  • 文档链接:https://stat.ethz.ch/R-manual/R-devel/library/base/html/quit.html.示例:`quit(save ="no",status = 1,runLast = FALSE)` (5认同)

小智 5

quit(status=1)
Run Code Online (Sandbox Code Playgroud)

替换1为您需要的任何退出代码。