s-news
[Top] [All Lists]

Re: extracting components of output

To: "'Spencer Graves'" <spencer.graves@PDF.COM>, JedSimons@aol.com
Subject: Re: extracting components of output
From: "Gunter, Bert" <bert_gunter@merck.com>
Date: Tue, 25 Mar 2003 07:58:20 -0500
Cc: s-news@lists.biostat.wustl.edu
Continuing ...

as.list(functionoutput) gives you access to the list components from the
function. This is what is formatted and printed by the relevant summary and
print methods that give you output. Read up on S-Plus (old) classes and
methods in the programmer's manual or Venable and Ripley's "S-Programming"
to learn what you need to know.

Bert Gunter
Biometrics Research RY 84-16
Merck & Company
P.O. Box 2000
Rahway, NJ 07065-0900
Phone: (732) 594-7765
mailto: bert_gunter@merck.com

"The business of the statistician is to catalyze the scientific learning
process."      -- George E.P. Box


-----Original Message-----
From: Spencer Graves [mailto:spencer.graves@PDF.COM]
Sent: Monday, March 24, 2003 4:59 PM
To: JedSimons@aol.com
Cc: s-news@lists.biostat.wustl.edu
Subject: Re: [S] extracting components of output


Typically though not always the output of a function is a list.  For 
this problem I first try "attributes", as illustrated in the following 
example:

 > tstFun <- function()
{
        list(a = 1, b = 2)
}
 > attributes(tstFun())
$names:
[1] "a" "b"

 > tstFun()$a
[1] 1
 > tstFun()[["a"]]
[1] 1
#########################
If this does not work, the problem is harder.  If this fails in your 
problem, please submit a more specific question.

Hope this helps,
Spencer Graves

JedSimons@aol.com wrote:
> I remember reading about a function which extracts just one component of 
> the output of another function.
> 
> eg if the output was from fitting a model, each word (or so) of the 
> output could be accessed an subscript index.
> 
> I cannot remember the name of the function, or find it anywhere.  Does 
> anyone happen to know ?  (I'm using Splus 6 under windows.)
> 
> Jed Simons
> Institute of Biotechnology
> UK


--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments, contains 
information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may 
be confidential, proprietary copyrighted and/or legally privileged, and is 
intended solely for the use of the individual or entity named in this message.  
If you are not the intended recipient, and have received this message in error, 
please immediately return this by e-mail and then delete it.

==============================================================================


<Prev in Thread] Current Thread [Next in Thread>