7

Possible Duplicate:
R: Display a time clock in the R command line

Is there any way to configure R so that it will display a time stamp before the prompt ">"?

Thanks a lot EC

Community
  • 1
  • 1
ECII
  • 10,297
  • 18
  • 80
  • 121
  • 2
    It's worth knowing that it's *even simpler* than the code used in the answer in that question. – John Colby Dec 12 '11 at 19:01
  • @JohnColby -- Very good point. Yours *is* simpler in my view (even though the help page for `addTaskCallback` claims the opposite). – Josh O'Brien Dec 12 '11 at 19:07
  • The *question* is still a dup though, so, I don't know, maybe I should just comment over there? – John Colby Dec 12 '11 at 19:10
  • @JohnColby Closing this as a dup is nothing to be afraid of; although it's _possible_ it could end up being deleted, that's unlikely since both questions have good answers that should be kept, and it might be a good merge candidate. – joran Dec 12 '11 at 19:20
  • @JohnColby: you could answer the other question with your less verbose solution. I voted to close because I prefer answers be in one place, rather than spread across multiple questions. – Joshua Ulrich Dec 12 '11 at 19:25
  • @JohnColby -- For the time being, I put a link over there to this answer as an alternative solution. – Josh O'Brien Dec 12 '11 at 19:58
  • @JoshO'Brien OK done. Thanks, Josh and Josh! – John Colby Dec 12 '11 at 20:13

1 Answers1

10

This will do it:

options(prompt=paste(Sys.time(),"> "))

I forget how to make it update though. I'll try to check when I get a sec...

Ahh found it:

updatePrompt <- function(...) {options(prompt=paste(Sys.time(),"> ")); return(TRUE)}
addTaskCallback(updatePrompt)
John Colby
  • 22,169
  • 4
  • 57
  • 69
  • Doesn't work for me, doesn't seem to get updated: 2011-12-12 19:07:22 > Sys.time() [1] "2011-12-12 19:08:00 CET" 2011-12-12 19:07:22 > Sys.time() [1] "2011-12-12 19:08:01 CET" 2011-12-12 19:07:22 > Sys.time() [1] "2011-12-12 19:08:02 CET" 2011-12-12 19:07:22 > Sys.time() [1] "2011-12-12 19:08:03 CET" 2011-12-12 19:07:22 > Sys.time() [1] "2011-12-12 19:08:03 CET" 2011-12-12 19:07:22 > Sys.time() [1] "2011-12-12 19:08:04 CET" 2011-12-12 19:07:22 > Sys.time() [1] "2011-12-12 19:08:04 CET" 2011-12-12 19:07:22 > Sys.time() [1] "2011-12-12 19:08:05 CET" 2011-12-12 19:07:22 > – ECII Dec 12 '11 at 18:08
  • This doesn't work on my mac using 2.14 in the GUI but it does work if I work with R from the terminal. – Dason Dec 12 '11 at 20:17