murdoch at stats.uwo.ca
Tue Feb 20 21:43:16 CET 2001
I need a function that's probably already in R, but I can't find it.
What I want is a "firstthat" function. This will look through a logical
vector and return the index of the first TRUE. Typical use would be like
x _ runif(100)
x[firstthat(x > 0.8)]
to find the first value in x that exceeds 0.8. If there are none, it
would give a zero length answer, or an NA, either would be fine. I need
the index, not just the first x value, because I'll also be making use of
corresponding values of some other variables.
If that's not already there, any suggestions for how best to write it?
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help