(Almost) Friday Function: alarm
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Last week I decided to start a weekly column detailing an interesting function each Friday, entirely forgetting that I would be on holiday, without internet access (shock horror!), tomorrow. So here’s your column a little early.
The alarm function is something of a novelty, in that all it does is to make an annoying noise when you call it. The only vaguely sensible time that I can think of that you might want to do this is when an error is thrown. Setting this up means overriding the default error handling behaviour, which is surprisingly easy.
options(error = alarm) stop("!!!") # to test the behaviour
For best results, make sure you’ve unplugged your headphones and turn the volume up loud to annoy friends, family and colleagues while debugging.
(To restore the default behaviour, use options(error = NULL)
.)
Tagged: alarm, friday-function, r
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.