Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I trap signals in R?

In bash I can trap SIGINT, SIGKILL, SIGTERM, and so on. That allows me to do different things depending how the program was unexpectedly stopped.

Is there a way to do this in R?

like image 298
isomorphismes Avatar asked Nov 10 '22 20:11

isomorphismes


1 Answers

Expanding a bit on my comment which OP asked me to post as an answer


The help file for conditions has the description

These functions provide a mechanism for handling unusual conditions, including errors and warnings.

There are many handling functions explained in the file, with examples. So I suggest starting with

help(conditions)
## and
example(conditions)

Additionally, tools::assertCondition might be worth a look too. It is linked at the bottom of the conditions documentation.

like image 51
Rich Scriven Avatar answered Nov 15 '22 07:11

Rich Scriven