[R] time (or output of function) in the R prompt

Liaw, Andy andy_liaw at merck.com
Thu Apr 11 20:11:06 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.

Thanks a lot Thomas!  This gives the same desired effect, thru different
mechanism (than the Unix shells?).  I can also use it to add the output of
getwd() to remind myself which R session I'm staring at, when I have several
running simultaneously.

Also thanks to DTL for providing taskCallbackManager().  It's a lot more
useful than my original question about timed autosave.

Cheers,
Andy


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message.  If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it.

==============================================================================

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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