[R] Last expression entered by user

Gabor Grothendieck ggrothendieck at gmail.com
Sun Aug 2 13:11:43 CEST 2009


Try this:

> x <- 4
> x*x+3
[1] 19
> savehistory(".Rhistory")
> c(parse(text = tail(readLines(".Rhistory"), 2)[1]))
expression(x * x + 3)


On Sun, Aug 2, 2009 at 5:02 AM, Daniel Haase<dh at haase-zm.de> wrote:
> Hi,
>
> I am looking for a way to find out the last expression that was entered by
> the user, similar to ".Last.value", but for the unevaluated expression
> instead of the evaluated one.
>
> Example:
>>
>> x <- 4
>> x*x + 3
>
> [1] 19
>>
>> .Last.value # that's the evaluated last expression
>
> [1] 19
> # but I am looking for the unevaluated expression (".Last.expression", so to
> say), which would be expression(x * x + 3) in this case
>
> Daniel
>
> ______________________________________________
> 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.
>




More information about the R-help mailing list