[R] How to retrieve results of most recent command?

Yeh, Richard C richard.c.yeh at bankofamerica.com
Fri Sep 22 18:09:05 CEST 2006

That's perfect!  Thanks!

I now see that .Last.value is mentioned in the 'Introduction to R',
footnote 5.  Sorry, I hadn't read it that carefully.

(Before posting, I even did read
> help('.Last')
but thought that that function wasn't what I wanted.
I guess I wasn't using the right keywords.
> help.search('last')
returns .Last.value as the top hit.

(I also apologize for the long disclaimer at the end.  It's
automatically generated.) 

212-933-3305 / richard.c.yeh at bankofamerica.com 
-----Original Message-----
From: Barry Rowlingson [mailto:B.Rowlingson at lancaster.ac.uk] 
Sent: Friday, September 22, 2006 11:59 AM
To: Yeh, Richard C
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] How to retrieve results of most recent command?

Yeh, Richard C wrote:
> In R, is there an automatic variable that stores the results of the
> recent command or commands?  (I am thinking of a behavior like
> Mathematica's % result-history substitution syntax.)

Something like .Last.value:

  > x=sqrt(2)
  > .Last.value
  [1] 1.414214

which might get more usage if it was less fiddly to type.


NOTICE TO RECIPIENTS: Any information contained in or attached
to this message is intended solely for the use of the intended
recipient(s). If you are not the intended recipient of this
transmittal, you are hereby notified that you received this
transmittal in error and we request that you please delete and
destroy all copies and attachments in your possession, notify
the sender that you have received this communication in error,
and note that any review or dissemination of, or the taking of
any action in reliance on, this communication is expressly

Banc of America Securities LLC ("BAS") does not accept time
sensitive, action-oriented messages or transaction orders,
including orders to purchase or sell securities, via e-mail.

Regular internet e-mail transmission cannot be guaranteed to be
secure or error-free.  Therefore, we do not represent that this
information is complete or accurate and it should not be relied
upon as such.  If you prefer to communicate with BAS using secure
(i.e., encrypted) e-mail transmission, please notify the sender.
Otherwise, you will be deemed to have consented to communicate
with BAS via regular internet e-mail transmission.  Please note
that BAS reserves the right to intercept, monitor, and retain all
e-mail messages (including secure e-mail messages) sent to or
from its systems as permitted by applicable law.

IRS Circular 230 Disclosure:

Bank of America Corporation and its affiliates, including BAS,
("Bank of America") do not provide tax advice. Accordingly, any
statements contained herein as to tax matters were neither written
nor intended by the sender or Bank of America to be used and cannot
be used by any taxpayer for the purpose of avoiding tax penalties
that may be imposed on such taxpayer. If any person uses or refers
to any such tax statement in promoting, marketing or recommending a
partnership or other entity, investment plan or arrangement to any
taxpayer, then the statement expressed above is being delivered to
support the promotion or marketing of the transaction or matter
addressed and the recipient should seek advice based on its
particular circumstances from an independent tax advisor.

More information about the R-help mailing list