[R] A shorter version of ".Last.value"?

Jon Zadra zadra at virginia.edu
Mon Jul 7 20:03:25 CEST 2008


Hi,

There is an object, ".Last.value" to which the result of the most recent 
evaluation is assigned.  This is similar to "ans" in Matlab.  In Matlab 
"ans" can be very useful and time-saving, but typing the larger R 
version is somewhat clunky and takes away from the usefulness.

Is it possible to reassign '.Last.value' to something simpler, like 'ans' ?

I'm aware of this thread: 
http://tolstoy.newcastle.edu.au/R/help/00b/1598.html, where a function 
such as:

ans <- function() {
  return(.Last.value)
  }

is discussed, however it would be nice not to have to type the () every 
time.  Is it possible to change something in R to essentially replace 
the location where ".Last.value" has the recent evaluation assigned to 
it with 'ans' instead?  Or might it be possible to make an object 'ans' 
that updates its value from ".Last.value" each time it is called?

Thanks,

Jon
-- 
Jon Zadra
Department of Psychology
University of Virginia
P.O. Box 400400
Charlottesville VA 22904
(434) 982-4744
email: zadra at virginia.edu
<http://www.google.com/calendar/embed?src=jzadra%40gmail.com>



More information about the R-help mailing list