如何使执行暂停,睡眠,等待中的R X秒? [英] How to make execution pause, sleep, wait for X seconds in R?

查看:411
本文介绍了如何使执行暂停,睡眠,等待中的R X秒?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何暂停的R脚本几秒或毫秒为单位指定的号码?在许多语言中,有一个睡眠的功能,但?睡眠引用的数据集。和?暂停?等待不存在。

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.

推荐答案

请参阅帮助(Sys.sleep)

例如,从?Sys.sleep

testit <- function(x)
{
    p1 <- proc.time()
    Sys.sleep(x)
    proc.time() - p1 # The cpu usage should be negligible
}
testit(3.7)

屈服

> testit(3.7)
   user  system elapsed 
  0.000   0.000   3.704 

这篇关于如何使执行暂停,睡眠,等待中的R X秒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆