繁体   English   中英

在 RStudio 控制台中显示时间戳

[英]Showing the timestamp in RStudio console

简单的问题:有没有办法在 RStudio 控制台中添加时间戳? 而不是控制台只显示这个:

>"This is my code"

它会将此(执行后)转换为

[HH:MM:SS]> "This is my code"
[1] "This is my code"

最简单的方法是使用Sys.time()

this is my code
Sys.time()

在未来的 RStudio 版本中,可能会为用户脚本分配快捷方式。

然后,您可以创建一个函数,该函数将执行代码并通过按ctrl + enter始终输出您想要的任何统计信息。 RStudio 无法为每个人猜测这些统计数据,如果我想要结束时间和开始时间怎么办? 执行时间如何? RStudio 和 R 很棒,但是是的,有时我们仍然需要自己做一些事情,比如编写我们自己该死的统计数据。

 Kevin UsheySeptember 15, 2015 12:49 Hi Alain, Mapping keyboard shortcuts to user scripts is something we have in the pipeline, but we haven't yet completed that work. Stay tuned! Best, Kevin

您可以尝试使用taskCallbackManager - 每次调用函数时都会对其进行评估:

new_prompt <- taskCallbackManager()

new_prompt$add(function(expr, value, ok, visible) {
  options("prompt" = format(Sys.time(), "[%H:%M:%S]> "));
  return(TRUE) },
  name = "promptHandler") 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM