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

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Mon, 07 Jul 2008 14:16:08 -0400

Try this:

> makeActiveBinding("ans", function() .Last.value, .GlobalEnv)
NULL
> yy <- 3
> ans

[1] 3

On Mon, Jul 7, 2008 at 2:03 PM, Jon Zadra <zadra_at_virginia.edu> wrote:
> 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>
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 07 Jul 2008 - 18:22:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 07 Jul 2008 - 19:31:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive