[19303] in s-news-athena
[S] Yet Another Vectorization Question
daemon@ATHENA.MIT.EDU (Kim Elmore)
Thu Sep 23 14:49:37 1999
Date: Thu, 23 Sep 1999 13:38:49 -0500 (CDT)
From: Kim Elmore <elmore@nssl.noaa.gov>
To: S-News mail list <s-news@wubios.wustl.edu>
Message-Id: <Pine.GSO.4.10.9909231331390.9237-100000@ev.nssl.noaa.gov>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
I have a very simple operation that I'd like to vectorize.
However, I haven't figured out how to do it. Being an unrepentant Fortran
77 hacker, this vectorization stuff sometimes escapes me. Here's what I'm
after: within a data frame, I want to know what columns contain negative
values and I want the results returned as a logical vector.
This works, but uses looping:
test <- logical(0)
for (i in 1:100)
{
test[i] <- all(df[,i] < 0)
}
Surely there's a way to vectorize this. Please, somebody rescue
me from my ignorance!
Kim Elmore, [N5OP, PP ASMEL/Glider 2232456]
"All of Meteorology is divided into three parts: Yes, No and Maybe. The
greatest of these is Maybe." -- The original Latin appears to be garbled.
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news