Saturday, November 27, 2010

Value of last evaluated expression in R

R saves the value of last evaluated expression in a variable called .Last.value. You can directly use this variable instead of running the last expression again.

For example:

> x <- 1:10
> x^2
[1] 1 4 9 16 25 36 49 64 81 100
> y <- .Last.value
> y
[1] 1 4 9 16 25 36 49 64 81 100

No comments:

Post a Comment