Equivalent of “throw” in R

后端 未结 5 1157
有刺的猬
有刺的猬 2020-12-07 12:09

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 fun

5条回答
  •  余生分开走
    2020-12-07 12:16

    See help(tryCatch):

    Conditions are signaled by 'signalCondition'. In addition, the
    'stop' and 'warning' functions have been modified to also accept
    condition arguments.

    and later under 'See Also':

    'stop' and 'warning' signal conditions, and 'try' is essentially a simplified version of 'tryCatch'.

    so you probably want stop.

提交回复
热议问题