[R] time (or output of function) in the R prompt
Thomas Lumley
tlumley at u.washington.edu
Thu Apr 11 19:50:34 CEST 2002
On Thu, 11 Apr 2002, Liaw, Andy wrote:
> Dear R-help,
>
> Would it be possible to have the "prompt" option accept a function, such as
> date()? This way, I can easily deduce the elapse time of top level R
> expressions. This would be similar to how Unix shells handle their prompt
> variables.
You can almost do this with the taskCallback Manager
> h <- taskCallbackManager()
> h$add(function(expr, value, ok, visible) {
options(prompt=paste(date(),"> "));
return(TRUE)},
name="dateprompt")
Thu Apr 11 10:47:06 2002 > 1+1
[1] 2
Thu Apr 11 10:48:28 2002 >
I say `almost' because the time is updated only when you actually compute
something. If you just press <return> it doesn't change. Apart from that
it works.
-thomas
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list