本文介绍了相当于“抛出”在R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在R中抛出错误?我有一个函数需要一个数据框和一些列名,并与它们进行填充。如果列不存在,我希望该功能停止,并根据它停止所有功能。我看过恢复
和浏览
和 traceback
但是,他们似乎很接近但不是我正在寻找的。
解决方案
请参阅 help(tryCatch)
:
后面的另请参见:
所以你可能想要 stop
。
How does one "throw" an error in R? I have a function that takes a data frame and some column names and does stuff with them. If the columns don't exist, I want the function to stop and to stop all functions depending on it.
I have looked at recover
and browse
and traceback
but, well, they seemed to be close but not what I am looking for.
解决方案
See help(tryCatch)
:
and later under 'See Also':
so you probably want stop
.
这篇关于相当于“抛出”在R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!