A simple function with no arguments, alarm causes the computer to make a very brief sound when it is called.

Example. We put R to sleep for five seconds using Sys.sleep, then alarm is called five times with half-second delays between each call.
> Sys.sleep(5)
> for(i in 1:5){
+   alarm()
+   Sys.sleep(0.5)
+ }
Tip. Don’t forget to turn your speakers on.
Tip. Above I called alarm several times. I’ve used this function in the past when running long scripts, and I’ve found that one call isn’t always enough to draw my attention away from whatever else I’m working on.
Tip. An alternative to the alarm function is to use cat(“\a”).
Thank you. Thanks to Chris Barr for informing me of this great function!

Leave a Reply