s-news
[Top] [All Lists]

Re: Matrix question

To: Chushu Gu <chushugu@hotmail.com>
Subject: Re: Matrix question
From: Spencer Graves <spencer.graves@pdf.com>
Date: Sat, 25 Oct 2003 10:20:12 -0700
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <LAW11-OE452fLRofGON0000642b@hotmail.com>
References: <Law11-OE646X0ZB9zBo0000b3ad@hotmail.com> <3F9A4DE2.4020807@pdf.com> <Law11-OE65DhsXOcOHe0000b655@hotmail.com> <3F9AA47C.7030605@pdf.com> <LAW11-OE452fLRofGON0000642b@hotmail.com>
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
Have you considered the following: sum(apply(A2, 2,function(x)which(!x)[1]))?
hope this helps.  spencer graves

Chushu Gu wrote:

Thanks Spencer Graves,
My further question is that I am intertested in the sum of that vector (5,4,1,4), which is 14. Is that possible to finish it in one step so that I don't need to calculate that vector first, then sum it up. Chushu Gu

    ----- Original Message -----
    From: Spencer Graves <mailto:spencer.graves@pdf.com>
    To: Chushu Gu <mailto:chushugu@hotmail.com>
    Sent: Saturday, October 25, 2003 9:27 AM
    Subject: Re: [S] Matrix question

1. I don't understand your question.
    2.  Please "reply to all", as others might be able to answer, and
    still others may be interested in your further question and any
further responses.
    spencer graves

    Chushu Gu wrote:

Is there any easy way to sum it up?


----- Original Message ----- From: "Spencer Graves" <spencer.graves@pdf.com>
To: "Chushu Gu" <chushugu@hotmail.com>
Cc: <s-news@lists.biostat.wustl.edu>
Sent: Saturday, October 25, 2003 3:18 AM
Subject: Re: [S] Matrix question


With A2 = your matrix, I get your answer from "apply(A2, 2, function(x)which(!x)[1])".
hope this helps.  spencer graves

Chushu Gu wrote:

Dear All,

I have a matrix

T T F T
T T T T
T T F T
T F T F
F T T F
T F F T
F T F F

What I need is to get the first F location in every column. The result I want is (5,4,1,4), How I use "which" to conquer this problem?

Chushu Gu
--------------------------------------------------------------------
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



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