如何在R中返回错误消息?

pet*_*ner 40 r

我想知道如何在R中生成错误消息,特别是在函数内?

Jil*_*ina 86

既然你没有说明你真正想要的东西,我只能说一下

?message # prints a message but not stop execution
?warning # prints a warning message but not stop execution
?stop # stops execution of the current expression and executes an error action.
Run Code Online (Sandbox Code Playgroud)


use*_*745 9

只需stop()在函数/脚本中包含

如果您要显示错误消息,请stop()像这样将其包含在内

stop("This is an error message")
Run Code Online (Sandbox Code Playgroud)