There is a package beepr
, see also here:
beepr
is an R package that contains one function, beep()
, with one
purpose: To make it easy to play notification sounds on whatever
platform you are on. It is intended to be useful, for example, if you
are running a long analysis in the background and want to know when it
is ready.
See also this SO answer.
The following code will beep 5 times, one time per call to f
. This is because beep()
is in on.exit
that, like the name says, executes its argument(s) on exit of the function.
f <- function(x){
on.exit(beepr::beep())
Sys.sleep(x)
}
g <- function(s) {
for(i in 1:5) {
f(s)
}
}
g(1)