[R] Last expression entered by user
Romain Francois
romain.francois at dbmail.com
Sun Aug 2 13:29:45 CEST 2009
Or this;
remember <- function(expr, value, ok, visible) {
assign( ".Last.expr", expr, .GlobalEnv )
invisible( TRUE )
}
addTaskCallback(remember)
> x <- rnorm(
+ 10 )
> .Last.expr
x <- rnorm(10)
Romain
On 08/02/2009 01:11 PM, Gabor Grothendieck wrote:
> 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
--
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/tlNb : RGG#155, 156 and 157
|- http://tr.im/rw0p : useR! slides
`- http://tr.im/rw0b : RGG#154: demo of atomic functions
More information about the R-help
mailing list