How do you pause an R script for a specified number of seconds or miliseconds? In many languages, there is a sleep
function, but ?sleep
references a data set. And ?pause
and ?wait
don't exist.
The intended purpose is for self-timed animations. The desired solution works without asking for user input.
See
help(Sys.sleep)
.For example, from
?Sys.sleep
Yielding
Sys.sleep() will not work if the CPU usage is very high; as in other critical high priority processes are running (in parallel).
This code worked for me. Here I am printing 1 to 1000 at a 2.5 second interval.