R语言实现获取当前的时间以及让语言计算停顿下,这次介绍三个函数:
Sys.sleep()
Sys.time()
proc.time()
Sys.sleep()
让R语言在做计算时停顿下,减缓运行速度
#睡眠2秒Sys.sleep(2)
Sys.time()
获取当前的系统时间,达到秒的精度。
> Sys.time()[1] "2016-12-14 23:52:10 CST"
proc.time()
用于获取R语言软件到当前时刻的打开时间,可以用于统计某个程序的运行时间。
testit <- function(x){ p1 <- proc.time() Sys.sleep(x) proc.time() - p1 # The cpu usage should be negligible}> testit(3.7)用户 系统 流逝 0.00 0.00 3.71
来源于网络的总结:
plot(0:10,0:10, type="n")# let use the 'for' to put texts on graph:for(i in 1:10) text(i,i, paste("**", i))
## let retard steps 1 secplot(0:10,0:10, type="n")for(i in 1:9){ text(i,i, paste("step", i)) Sys.sleep(1) }
注明:上面两图需要实践方可明白喔!
联系客服