Dan Goldstein Dan Goldstein - 1 year ago 98
R Question

How to make execution pause, sleep, wait for X seconds in R?

How do you pause an R script for a specified number of seconds or miliseconds? In many languages, there is a

function, but
references a data set. And
don't exist.

The intended purpose is for self-timed animations. The desired solution works without asking for user input.

Answer Source

See help(Sys.sleep).

For example, from ?Sys.sleep

testit <- function(x)
    p1 <- proc.time()
    proc.time() - p1 # The cpu usage should be negligible


> testit(3.7)
   user  system elapsed 
  0.000   0.000   3.704 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download