s-news
[Top] [All Lists]

Re: extracting components of output

To: JedSimons@aol.com
Subject: Re: extracting components of output
From: Spencer Graves <spencer.graves@PDF.COM>
Date: Mon, 24 Mar 2003 13:58:35 -0800
Cc: s-news@lists.biostat.wustl.edu
References: <176.17ae129a.2bb0d2ce@aol.com>
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01
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



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