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
|