簡體   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